Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Referencing name not defined yet allowed by mypy, yet error at runtime. #17610

Description

@MarioIshac

To Reproduce

from collections.abc import Callable

class A:
    @staticmethod
    def b(c: Callable[[], None]) -> Callable[[], None]:
        return c
    
    @A.b
    @staticmethod
    def c() -> None:
        pass

mypy playground

Expected Behavior

Invoking mypy catches error.

Actual Behavior

Success: no issues found in 1 source file

However, at runtime:

NameError: name 'A' is not defined

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions