-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Disable mypy overload-overlap warnings? #12178
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
Comments
We should check how many become unused with the mypy master branch, as the way the lint works at mypy has just been completely reworked in python/mypy#17392. |
That sounds promising! |
So yes, these are mypy's new complaints regarding overload-overlap if you use mypy
And in our third-party stubs we have:
So in total that's around 60 that will go away altogether. That will still leave us with quite a few errors ignored in typeshed, and I agree we don't get much value from the check. (We already have pyright's version switched off, because it was even noisier than mypy's.) Diff I made to mypy to get --- a/mypy/errors.py
+++ b/mypy/errors.py
@@ -680,11 +680,6 @@ class Errors:
self.has_blockers.remove(path)
def generate_unused_ignore_errors(self, file: str) -> None:
- if (
- is_typeshed_file(self.options.abs_custom_typeshed_dir if self.options else None, file)
- or file in self.ignored_files
- ):
- return
ignored_lines = self.ignored_lines[file]
used_ignored_lines = self.used_ignored_lines[file]
for line, ignored_codes in ignored_lines.items(): Diff I made to our tests: diff --git a/tests/mypy_test.py b/tests/mypy_test.py
index cafaca811..431439509 100755
--- a/tests/mypy_test.py
+++ b/tests/mypy_test.py
@@ -270,6 +270,8 @@ def run_mypy(
"ignore-without-code",
"--enable-error-code",
"redundant-self",
+ "--disable-error-code",
+ "override",
"--config-file",
temp.name,
] |
My gut feeling says that we should disable the test even after the PR (as you also wrote), but maybe it's a good idea to do this after the next mypy release, as a baseline. |
Tbh, I kind of like these, despite the fact that we often have no choice but to ignore them. When reading stubs, they alert me to useful facts about the way overloads are structured. I would vote we prune down the ignores to match the state following python/mypy#17392 which gets rid of some of the least helpful ones (I'll open a PR soon so we can take a look). |
I'm actually now quite strongly opposed to disabling these warnings, given the spectrum of views in https://discuss.python.org/t/draft-typing-spec-chapter-for-overloads . Until we have specified behaviour of overloads, I think it's very useful to clearly call out areas where typeshed's needs in practice can inform that specification |
These mypy warnings are overzealous, as it's often quite useful to have partial overlaps: We ignore this warning in 192 places in typeshed at the moment, and I don't think we gain any benefit from having it enabled.
Ideally, mypy would have a separate warning for overloads that are completely shadowed by another overload, though.
The text was updated successfully, but these errors were encountered: