-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Please submit high-quality stubs for importlib #189
Comments
QQ about the |
That doesn't present any additional problems; the existing support for |
Any news? Or can I try to rewrite a cleaner version than #183? |
I'm still planning on writing the stubs in the next month or so (a bit swamped with Python 3.6 stuff ATM). |
Question for @gvanrossum: what directory should I put the stubs in? Importlib was introduced in Python 3.1, but a lot of things have been added over the years. Should I just put it into 3/ ? And how zealous should I be with version checks (e.g. a new method added in Python 3.4)? And a reminder to myself, I should check what attributes modules have by default and in what versions of Python they became defaults |
I would put it in 3/, and add sys.version_info checks around new methods. (Mypy currently ignores those, but eventually we will make it respect them, so you might as well put them in now.) |
I'm going to fix this issue step-by-step to make sure I'm doing it correctly, so I'm starting w/ I also noticed that the |
* Ignore VS Code * Add stubs for importlib.__init__ Part of #189
So I have a problem where mypy doesn't like the Liskov violation that was purposefully introduced into
One subclass overrides this method as:
Notice how The other subclass overrides the method as:
Notice how How do you want me to handle this to make mypy happy? |
Usually, I was doing in the sub classes def find_module(self, # type: ignore
fullname: str) -> Optional[Loader]: ... That indeed remove the warning by telling mypy to stop caring about it. That may not be the best way to handle it, but I don't see any other which works with the current state of mypy. |
Does mypy differentiate between instance, class, and static methods? I.e. is it worth redefining every method on a subclass if they are made e.g. classmethod? |
Mypy correctly distinguishes between the three types of methods (most of the time). I'm not sure what you're really asking -- if you really care, can you show a small example? |
I'm just trying to be lazy. :) Basically I have an ABC that defines some method |
I guess both PY3 and PY2 versions are wanted.
This came up in #183.
The text was updated successfully, but these errors were encountered: