Skip to content

Specifying int as type for self doesn't get flagged #1222

Closed
@gvanrossum

Description

@gvanrossum

This doesn't give any error:

class C:
    def foo(self: int) -> None:
        pass

C().foo()

We ran into this in PY2 mode: Benjamin removed an argument from a method but forgot to remove it from the # type signature, and then realized that mypy didn't catch that. The PY2 form of signatures in # type comments doesn't require a type corresponding to self but it allows it, so his mistake effectively boiled down to the above example. Why isn't this an error?

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