-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
FileFinder takes a class, not an instance (#7085) #7086
FileFinder takes a class, not an instance (#7085) #7086
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from __future__ import annotations
is implicitly enabled in stub files, so we can just use builtin type
instead of typing.Type
— this is what the flake8 error message was trying to flag.
(Do you have any feedback for how we could improve that flake8 error message, btw? 🙂)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have opened PyCQA/flake8-pyi#164 — we can definitely improve that error message :) As the person who, er, wrote the error message, I sincerely apologise for the confusion!! |
This comment has been minimized.
This comment has been minimized.
The FileFinder takes a tuple of (class, arguments) to instantiate for each time, rather than an existing instance. This fixes the type hint to match Python 3.10 reality. Issue: #7085
Perhaps |
Anyhow, I've squashed away the evidence of my confusion, and it should pass the lints now, thanks for your help! |
No problem!! |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
As for how I ended up here, due to some arguments and a slight insomnia I ended up writing a Python module to enforce type hints on all imports at run-time and not as a CI step. It turns out it ended up shooting itself as the importlib types didn't match reality <.< But once that was fixed, it actually works, with only slight side-effects (may include nausea, sluggishness and ImportErrors.) |
Thank you! (And thanks Alex for improving the message) |
The FileFinder takes a tuple of (class, arguments) to instantiate for
each time, rather than an existing instance.
This fixes the type hint to match Python 3.10 reality.
Issue: #7085