Skip to content

Method/attribute of same name of return type fail to typecheck #1897

Closed
@tharvik

Description

@tharvik
class A: pass

class B:
    def A(self) -> A: pass

B().A()

is a valid python code, but mypy

/tmp/asd.py: note: In function "A":
/tmp/asd.py:4: error: Invalid type "A"

It was found while typing datetime.datetime.tzinfo which return a tzinfo.

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