Uh oh!
There was an error while loading. Please reload this page.
make __class__ refer to the current object's class - #1549
Conversation
matthiaskramm
commented
Sep 27, 2017
Happy to merge this, but I think you'll need to resolve conflicts first. |
JelleZijlstra
commented
Sep 27, 2017
Thanks! Hadn't noticed there was a merge conflict. |
gvanrossum
commented
Sep 29, 2017
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 ifSupportedTrackedTaskWorkers.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.
JelleZijlstra
commented
Sep 29, 2017
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. |
gvanrossum
commented
Sep 29, 2017
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')
classSuperDestroyable(Generic[_DClass, _ActClass]): |
JelleZijlstra
commented
Sep 29, 2017
I wonder if the second one is actually a bug in your code. |
gvanrossum
commented
Sep 29, 2017
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: importthreadingclassC(threading.local):
deffoo(self) ->None:
reveal_type(self) # Creveal_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 |
gvanrossum
commented
Sep 29, 2017
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.
ilevkivskyi
commented
Sep 30, 2017
t: typex: 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.
Fixespython/mypy#3061