Skip to content

type(self) not handled properly #648

Open
@ndmitchell

Description

@ndmitchell

Describe the Bug

class Foo:
    @classmethod
    def method(cls, x: str) -> None:
        ...
    
    def g(self):
        type(self).method("tst") # E: Object of class `type` has no attribute `method`

This gives an error in Pyrefly, but works with mypy and Pyright.

Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAEBiD28BcAoa7oAFSQgWwFMAXAC3gBM0NyCAzaQ0igClAgBpoAPJaCIgE4BKaAFoAfNABy8AHYFUGJdAB0aqug3Qa9AObMIBELSGLl6IgE8ADgQNGTKxmXLMAREX5uhKIA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

UserBugs reported by external users that should be prioritisedpytorch

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions