Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

track if typing.TYPE_CHECKING to warn about non runtime bindings #622

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Feb 9, 2024

  1. track if typing.TYPE_CHECKING to warn about non runtime bindings

    When importing or defining values in ``if typing.TYPE_CHECKING`` blocks
    the bound names will not be available at runtime and may cause errors
    when used in the following way::
    
      import typing
    
      if typing.TYPE_CHECKING:
        from module import Type  # some slow import or circular reference
    
      def method(value) -> Type:  # the import is needed by the type checker
        assert isinstance(value, Type)  # this is a runtime error
    
    This change allows pyflakes to track what names are bound for runtime
    use, and allows it to warn when a non runtime name is used in a runtime
    context.
    terencehonles committed Feb 9, 2024
    Configuration menu
    Copy the full SHA
    8c4da4a View commit details
    Browse the repository at this point in the history