-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
isinstance with self.__class__ infers 'object' as the type #3061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A slightly more straightforward way to repro: from typing import Any
class A:
def f(self, o: Any) -> None:
if isinstance(o, self.__class__):
reveal_type(o) # builtins.object |
It should be fixable by changing typeshed: class object:
@property
def __class__(self: _T) -> Type[_T]: ... Seems to work (at least for this particular case). reveal_type(o) # Revealed type is 'tmp.A*' |
@elazarg's proposed typeshed change isn't quite right because |
This should be reopened since python/typeshed#1549 was reverted in python/typeshed#1632. |
@gvanrossum I think the original PR can be simply re-applied, since the issue that caused reverting it should be fixed now. |
Could you give that a try?
…On Wed, Mar 7, 2018, 10:25 Ivan Levkivskyi ***@***.***> wrote:
@gvanrossum <https://github.com/gvanrossum> I think the original PR can
be simply re-applied, since the issue that caused reverting it should be
fixed now.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3061 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMlguaaAbVhtjSo3pTNniNmMSkYsJks5tcCYvgaJpZM4MqaIR>
.
|
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 |
@gvanrossum Unfortunately, there are still some problems with python/typeshed#1951, I will investigate next week. |
Any luck with this one? It would be great to have the insurance that |
@mlhamel Unfortunately core mypy team is overloaded with other tasks plus two team members are on vacation now. |
@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 |
@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 |
An unexpected type is revealed by this program:
The issue was introduced by #2997. The most precise type would be
A
. Mypy used to inferAny
as the type before #2997.The text was updated successfully, but these errors were encountered: