Repository navigation
Direct import for metaclass ABCMeta - #640
Conversation
|
That is very strange. Why is that needed? If you don't know, I suggest you research it further before answering. :-) |
|
I can't say I know for sure, but I have a strong suspicion. I believe this is due to the priority given to Perhaps this can be changed from inside mypy; if so, I can put this PR on hold. But the solutions I came up with were ugly hacks. |
| # - ModuleSpec in importlib.machinery (3.4 and later only) | ||
|
|
||
| import abc | ||
| from abc import ABCMeta |
There was a problem hiding this comment.
In this case I'd say add abstractmethod too and get rid of the previous line (import abc), and modify all @abc.abstractmethod to @abstractmethod.
|
OK, I think that is actually reasonable. A tweak just in mypy might be to detect that a class or other object in an imported module is used in a position where it is immediately needed (e.g. base class, metaclass, decorator) but that feels fairly hard since all those calculations have to be done in |
The Python 2 version is very close to the Python 3.6 code.
Added
from abc import ABCMetain importlib.This change is needed for mypy/#2365.