Skip to content

mypy not catching needing to specify a forward declaration. #4764

Closed
@asincero

Description

@asincero

Steps to reproduce

mypy doesn't detect the need for a forward declaration. For example:

class Foo:
    def bar(o: Foo) -> None:
        print('bar called')
        
o = Foo()
o.bar()

Current behavior

mypy doesn't detect anything wrong with the above code.

Expected behavior

mypy should flag the reference to "Foo" on line 2 as being undefined.

mypy --version output

mypy 0.570

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions