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
{{ message }}
Repository navigation
Same name for instance and type object may be confusing #3372
A type object and an instance of that type are often printed in the same way:
$ mypy -c'True.x'
<string>:1: error: "bool" has no attribute "x"
$ mypy -c'bool.x'
<string>:1: error: "bool" has no attribute "x"
Most of the time this is OK, although when metaclasses are involved it becomes confusing. But even without metaclasses, simply forgetting to instantiate a class results in an error that does not make sense:
classA: passclassB(A): passdeff(a: A): passf(B) # E: Argument 1 to "f" has incompatible type "B"; expected "A"a: A=B# E: Incompatible types in assignment (expression has type "B", variable has type "A")
But of course "B" is compatible with "A". It's the type object "B" that is incompatible with "A".
In the above example, passing A to f gives a more explicit error saying that "B" is a type object, but this is done while trying to give distinct name for each type, so this does not solve the general problem.
Activity
refi64 commentedon May 16, 2017
I think this is a dup? I recall a very similar issue coming up before...
elazarg commentedon May 16, 2017
I can't find it :\
ilevkivskyi commentedon May 16, 2017
@elazarg
Here is the issue #3050 could you please copy your example there? (I am closing this as a duplicate)
elazarg commentedon May 16, 2017
Yes I just found it... I will. Thanks