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
isinstance with self.__class__ infers 'object' as the type #3061
@elazarg's proposed typeshed change isn't quite right because __class__ is writable. Though I suppose if you assign to __class__ there's little hope for typechecking your code. I'll try adding a setter.
@mlhamel TBH I don't remember now what exactly was the problem with python/typeshed#1951 that should fix this. I just remember that there was some weird interaction with classes that have an Any base class. One thing you can help with is if you have some large code bases could you try locally applying python/typeshed#1951 and checking if there are any problems with it.
Activity
JukkaL commentedon Mar 27, 2017
A slightly more straightforward way to repro:
elazarg commentedon Mar 27, 2017
It should be fixable by changing typeshed:
Seems to work (at least for this particular case).
pkch commentedon Mar 28, 2017
@elazarg I think that's a good fix. It should probably be combined with #3056.
JelleZijlstra commentedon Aug 15, 2017
@elazarg's proposed typeshed change isn't quite right because
__class__is writable. Though I suppose if you assign to__class__there's little hope for typechecking your code. I'll try adding a setter.make __class__ refer to the current object's class
make __class__ refer to the current object's class (#1549)
gvanrossum commentedon Feb 27, 2018
This should be reopened since python/typeshed#1549 was reverted in python/typeshed#1632.
ilevkivskyi commentedon Mar 7, 2018
@gvanrossum I think the original PR can be simply re-applied, since the issue that caused reverting it should be fixed now.
gvanrossum commentedon Mar 7, 2018
ilevkivskyi commentedon Mar 7, 2018
Here is the PR python/typeshed#1951. I checked manually that it doesn't cause problems you mentioned in python/typeshed#1549 (comment) (will run
testprtomorrow).ilevkivskyi commentedon Mar 9, 2018
@gvanrossum Unfortunately, there are still some problems with python/typeshed#1951, I will investigate next week.
mlhamel commentedon Aug 16, 2018
Any luck with this one?
It would be great to have the insurance that
__class__(self: _T) -> Type[_T]: ...ilevkivskyi commentedon Aug 17, 2018
@mlhamel Unfortunately core mypy team is overloaded with other tasks plus two team members are on vacation now.
mlhamel commentedon Aug 17, 2018
@ilevkivskyi no worries i was mostly just wondering if there was anything new but if i can help in any way I would be pleased to give a try
ilevkivskyi commentedon Aug 18, 2018
@mlhamel TBH I don't remember now what exactly was the problem with python/typeshed#1951 that should fix this. I just remember that there was some weird interaction with classes that have an
Anybase class. One thing you can help with is if you have some large code bases could you try locally applying python/typeshed#1951 and checking if there are any problems with it.