You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classFoo:
@classmethoddefclassm(cls, a: int, b: str) ->Foo:
reveal_type(cls) # E: Revealed type is 'def () -> classm.Foo'returncls(a, b) # E: Too many arguments for "Foo"def__init__(self, a: int, b: str) ->None:
self.a=aself.b=b
Apparently, we eagerly bind the cls parameter of a classmethod to the type as it exists when semanal.py visits the classmethod. If that is before __init__ has been defined, then we incorrectly infer that cls takes no arguments. It works as expected (no errors; reveal_type says cls takes two parameters) if I put classm after __init__.
The text was updated successfully, but these errors were encountered:
JelleZijlstra
changed the title
classmethod define before __init__ sees incorrect signature
classmethod defined before __init__ sees incorrect signature
May 19, 2017
Apparently, we eagerly bind the cls parameter of a classmethod to the type as it exists when semanal.py visits the classmethod. If that is before
__init__
has been defined, then we incorrectly infer thatcls
takes no arguments. It works as expected (no errors; reveal_type says cls takes two parameters) if I putclassm
after__init__
.The text was updated successfully, but these errors were encountered: