Always allow returning Any from lambda#15413
Merged
hauntsaninja merged 2 commits intopython:masterfrom Jun 11, 2023
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
|
Always* 😄 |
hauntsaninja
approved these changes
Jun 11, 2023
Collaborator
hauntsaninja
left a comment
There was a problem hiding this comment.
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
Contributor
|
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]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.