Skip to content

Definitions under TYPE_CHECKING should not be importable #3629

@rexledesma

Description

@rexledesma

Describe the Bug

In trying to make our codebase generally compliant with quoted annotations, we ran into the issue of identifying modules that were unintentionally importing definitions as a re-export, rather from the file of definitional source of truth.

When converting to quoted annotations, these re-exports become nested in a conditional, and should no longer be importable to other modules. However, pyrefly does not flag this.

Similar to #3624, we should not include these declarations.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0AVAJoAFAKIB9AMIAJMVIDSASQByAcQA66LRDCDRk2fOXrEWuhbr46AXjoBGEABoQ2EuURVadNFjzWuHj4rZxAyShgwKFJCBlooCgBiOhFSCKjSHwwcAjoAY1x0SDYAV0pUBghCwi1kgGUYGDoACwYGYjhEAHou8Mjowl42Lph0LsxcPLgugqKIUvLKwq66MF46VAA3VGhUbFh8wuKyiqr0OlxiJfQ4GvQyBmbCgFpNmEo4M9s6DRAAZkI9gATL8tABtd7UD4AXS0JXQgV4DBgmGemAgETylTe3wA5PN0LwYLitISGM8IgBHEoYlHPADWMFIz1QeTy8DgeIA7qhKOgSegQABfFys7EwABi0BgFDcZGFQA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions