You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
So yes, these are mypy's new complaints regarding overload-overlap if you use mypy master, fiddle with mypy's master branch so that you get rid of the thing where it stops --warn-unused-ignores from working inside typeshed directories, then fiddle with our mypy_test.py so that it ignores the override error code (because there's a bunch of new errors from that error code on mypy master which are unrelated to the thing we're discussing here), and then run python tests/mypy_test.py stdlib -p3.13:
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 --warn-unused-ignore working:
Details
--- 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():
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
Activity
AlexWaygood commentedon Jun 20, 2024
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.
srittau commentedon Jun 20, 2024
That sounds promising!
AlexWaygood commentedon Jun 20, 2024
So yes, these are mypy's new complaints regarding overload-overlap if you use mypy
master, fiddle with mypy'smasterbranch so that you get rid of the thing where it stops--warn-unused-ignoresfrom working inside typeshed directories, then fiddle with ourmypy_test.pyso that it ignores theoverrideerror code (because there's a bunch of new errors from that error code on mypymasterwhich are unrelated to the thing we're discussing here), and then runpython tests/mypy_test.py stdlib -p3.13:Details
And in our third-party stubs we have:
Details
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
--warn-unused-ignoreworking:Details
Diff I made to our tests:
Details
srittau commentedon Jun 20, 2024
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.
Disable mypy error-code overload-overlap
hauntsaninja commentedon Aug 2, 2024
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).
hauntsaninja commentedon Aug 17, 2024
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
srittau commentedon Jul 11, 2026
No concensus.