-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
make __class__ refer to the current object's class #1549
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
Conversation
Happy to merge this, but I think you'll need to resolve conflicts first. |
Thanks! Hadn't noticed there was a merge conflict. |
I wonder if we should revert this? I just checked our internal codebases against this and I found some mysterious new mypy errors all complaining about the use of
The code for the first was (in a class derived from if SupportedTrackedTaskWorkers.is_supported(self.__class__.__name__, self.task_name): and for the second (in a generic class): concrete_class = self.__class__ # type: Type[_DClass] Let me know if you have more questions about context. |
This reverts commit 1a164b6.
I'm OK with reverting for now (#1632). It's not obvious to me where these errors are coming from but I'll look into it. |
I don't understand either. I should add that the second one perhaps gives a better clue, as it appears inside the _DClass = TypeVar('_DClass', bound='SuperDestroyable')
_ActClass = TypeVar('_ActClass')
class SuperDestroyable(Generic[_DClass, _ActClass]): |
I wonder if the second one is actually a bug in your code. |
Oh, interesting. I'll ask the author of the code -- it seems |
I'm also going to try and boil down the first. I came up with this, and while it doesn't give the same error, it does seem relevant: import threading
class C(threading.local):
def foo(self) -> None:
reveal_type(self) # C
reveal_type(self.__class__) # Type[C]
reveal_type(self.__class__.__name__) # Any ?!?! The actual production code shows the same phenomenon. When I remove the So somehow the weirdness in the definition of |
I have to punt on this for now. I'm going to merge the typeshed sync and cut the release branch now. |
This is to pick up the revert of python/typeshed#1549.
t: type
x: Type[int] = t # this is considered safe because of implicit Any
|
This is just a direct rehash of #1549.
This is just a direct rehash of python#1549.
Fixes python/mypy#3061