-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Always allow returning Any from lambda #15413
Conversation
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.
Makes sense!
This comment has been minimized.
This comment has been minimized.
Always* 😄 |
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.
Looks good! --warn-return-any
isn't fully sound as it is, I think this is a reasonable place to relax and primer gets rid of a number of ignored errors
Diff from mypy_primer, showing the effect of this PR on open source code: poetry (https://github.com/python-poetry/poetry)
+ src/poetry/json/__init__.py:27: error: Unused "type: ignore" comment [unused-ignore]
- src/poetry/packages/locker.py:366: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
+ src/poetry/packages/locker.py:435: error: Unused "type: ignore" comment [unused-ignore]
- src/poetry/puzzle/provider.py:129: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/repositories/test_pypi_repository.py:277: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/repositories/test_pypi_repository.py:305: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/repositories/test_legacy_repository.py:189: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/repositories/test_legacy_repository.py:202: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/repositories/test_legacy_repository.py:375: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- src/poetry/console/commands/show.py:435: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- src/poetry/console/commands/show.py:484: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:418: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:421: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:449: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:452: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:479: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:482: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:510: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:513: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:540: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:543: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:571: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
- tests/puzzle/test_provider.py:574: error: Returning Any from function declared to return "SupportsDunderLT[Any] | SupportsDunderGT[Any]" [no-any-return]
werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/testapp.py:136: error: Unused "type: ignore" comment [unused-ignore]
pylint (https://github.com/pycqa/pylint)
+ pylint/pyreverse/diagrams.py:152: error: Unused "type: ignore" comment [unused-ignore]
+ pylint/pyreverse/writer.py:82: error: Unused "type: ignore" comment [unused-ignore]
+ pylint/checkers/similar.py:608: error: Unused "type: ignore" comment [unused-ignore]
+ pylint/checkers/variables.py:300: error: Unused "type: ignore" comment [unused-ignore]
+ pylint/checkers/base/name_checker/checker.py:348: error: Unused "type: ignore" comment [unused-ignore]
Auto-Split (https://github.com/Avasam/Auto-Split)
- src/AutoSplit.py:107: error: Returning Any from function declared to return "None" [no-any-return]
- src/AutoSplit.py:195: error: Returning Any from function declared to return "None" [no-any-return]
- src/AutoSplit.py:198: error: Returning Any from function declared to return "None" [no-any-return]
isort (https://github.com/pycqa/isort)
+ isort/settings.py:863: error: Unused "type: ignore" comment [unused-ignore]
+ isort/literal.py:89: error: Unused "type: ignore" comment [unused-ignore]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/streams.py:70: error: Unused "type: ignore[no-any-return]" comment [unused-ignore]
bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/simple.py:186: error: Unused "type: ignore" comment [unused-ignore]
+ src/bandersnatch/simple.py:222: error: Unused "type: ignore" comment [unused-ignore]
streamlit (https://github.com/streamlit/streamlit) got 1.10x faster (69.0s -> 62.6s)
+ lib/streamlit/runtime/legacy_caching/hashing.py:554: error: Unused "type: ignore" comment [unused-ignore]
- lib/tests/streamlit/watcher/local_sources_watcher_test.py: note: In function "sort_args_list":
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:372:47: error: Returning Any from function declared to return "Union[SupportsDunderLT[Any], SupportsDunderGT[Any]]" [no-any-return]
- lib/tests/streamlit/elements/element_utils_test.py:52:46: error: Returning Any from function declared to return "None" [no-any-return]
- lib/tests/streamlit/elements/element_utils_test.py:63:50: error: Returning Any from function declared to return "None" [no-any-return]
- lib/tests/streamlit/form_test.py: note: In member "test_exception_for_callbacks_on_widgets" of class "FormStateInteractionTest":
- lib/tests/streamlit/form_test.py:341:75: error: Returning Any from function declared to return "None" [no-any-return]
- lib/tests/streamlit/form_test.py: note: In member "test_no_exception_for_callbacks_on_submit_button" of class "FormStateInteractionTest":
- lib/tests/streamlit/form_test.py:347:54: error: Returning Any from function declared to return "None" [no-any-return]
|
Fixes #9656
Although it is not clear this is actually a bug, it is kind of inconsistent to say "Returning Any from function declared to return ..." for lambdas, that never have annotations, their types are always inferred, not declared. Also it is a surprisingly popular issue that is a one line fix, so I think we should do it.