Skip to content

Pyrefly inserted typing import in sub-optimal location #1490

Closed

Description

@rchen152

Describe the Bug

When I started typing ClassVar in a file in which I hadn't imported typing.ClassVar, Pyrefly brought up ClassVar as a completion suggestion (very helpful!), but it inserted from typing import ClassVar at the very top of my imports list. Ideally, it would have merged ClassVar into my existing from typing import ... line, or at least inserted the new typing import line right above/below the existing one.

Image

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Activity

  1. added theissue type on Nov 4, 2025
  2. added
    language-serverIssues specific to our IDE integration rather than type checking
    on Nov 4, 2025
  3. yangdanny97 commented on Nov 4, 2025

    @yangdanny97
    Collaborator

    Do formatters automatically sort/merge imports? If so, I imagine this wouldn't be an issue for folks that have a format-on-save turned on

  4. rchen152 commented on Nov 4, 2025

    @rchen152
    ContributorAuthor

    Ah, good point. When I have format-on-save turned on, the formatter does combine the import lines on save.

  5. KRRT7 commented on Nov 5, 2025

    @KRRT7

    pyrefly did a similar thing where it did the import above from __future__ import annotations which is incorrect

  6. asukaminato0721 commented on Jul 8, 2026

    @asukaminato0721
    Collaborator

    #claim

  7. github-actions commented on Jul 8, 2026

    @github-actions

    @asukaminato0721 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

has-open-prlanguage-serverIssues specific to our IDE integration rather than type checking

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions