Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Sep 13, 2023

As discussed in #7511, mypy's --warn-no-return isn't really a question of type safety. It does however enforce a PEP 8 rule that is "dear to Guido's heart", and I think we should enforce it for functions that explicitly return Any as well.

Fixes #16095

As discussed in python#7511, mypy's
`--warn-no-return` isn't really a question of type safety. It does
however enforce a rule that is "dear to Guido's heart", and I think we
should enforce it for functions that explicitly return Any as well.

Fixes python#16095
@github-actions

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator Author

Hmm, more hits than I was hoping for. Most of them are PEP 8 violations, the few that are not should straightforwardly be -> None. Still, might eat more into our disruption budget than we want.

@github-actions

This comment has been minimized.

@hauntsaninja hauntsaninja marked this pull request as ready for review September 14, 2023 01:07
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also test correct cases to be correct.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

porcupine (https://github.com/Akuli/porcupine)
+ porcupine/_state.py:41: error: Missing return statement  [return]

pylox (https://github.com/sco1/pylox)
+ pylox/callable.py:41: error: Missing return statement  [return]

comtypes (https://github.com/enthought/comtypes)
+ comtypes/tools/tlbparser.py:583: error: Missing return statement  [return]

jinja (https://github.com/pallets/jinja)
+ src/jinja2/utils.py:131: error: Missing return statement  [return]
+ src/jinja2/visitor.py:44: error: Missing return statement  [return]

zetta_utils (https://github.com/ZettaAI/zetta_utils)
+ zetta_utils/builder/build.py:100: error: Missing return statement  [return]

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/visualization.py:51: error: Missing return statement  [return]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/display.py: note: In function "__call__":
+ sphinx/util/display.py:90:9: error: Missing return statement  [return]
+ sphinx/testing/fixtures.py: note: In member "store" of class "SharedResult":
+ sphinx/testing/fixtures.py:43:5: error: Missing return statement  [return]

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/utilities/type_info.py:276: error: Missing return statement  [return]
+ src/graphql/execution/execute.py:1805: error: Missing return statement  [return]

vision (https://github.com/pytorch/vision)
+ torchvision/transforms/v2/_misc.py:106: error: Missing return statement  [return]
+ torchvision/transforms/v2/_misc.py:166: error: Missing return statement  [return]

sublime_debugger (https://github.com/daveleroy/sublime_debugger)
+ modules/core/sublime.py:71: error: Missing return statement  [return]
+ modules/output_panel.py:328: error: Missing return statement  [return]
+ modules/adapters/js.py:64: error: Missing return statement  [return]

bandersnatch (https://github.com/pypa/bandersnatch)
+ src/bandersnatch/master.py: note: In member "rpc" of class "Master":
+ src/bandersnatch/master.py:191: error: Missing return statement  [return]

spark (https://github.com/apache/spark)
+ python/pyspark/sql/types.py:1161: error: Missing return statement  [return]
+ python/pyspark/sql/types.py:1165: error: Missing return statement  [return]
+ python/pyspark/ml/torch/data.py:38: error: Missing return statement  [return]
+ python/pyspark/sql/connect/client/reattach.py:299: error: Missing return statement  [return]
+ python/pyspark/pandas/frame.py:13243: error: Missing return statement  [return]
+ python/pyspark/pandas/resample.py:736: error: Missing return statement  [return]
+ python/pyspark/pandas/resample.py:768: error: Missing return statement  [return]

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/parameters.py: note: In member "example" of class "PayloadAlternatives":
+ src/schemathesis/parameters.py:92: error: Missing return statement  [return]
+ src/schemathesis/specs/openapi/parameters.py: note: In member "example" of class "OpenAPIParameter":
+ src/schemathesis/specs/openapi/parameters.py:26: error: Missing return statement  [return]

ignite (https://github.com/pytorch/ignite)
+ ignite/engine/engine.py:252: error: Missing return statement  [return]
+ ignite/distributed/auto.py:354: error: Missing return statement  [return]
+ ignite/contrib/handlers/neptune_logger.py:163: error: Missing return statement  [return]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/decorators.py:613: error: Missing return statement  [return]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ gridfs/grid_file.py: note: In function "_grid_in_property":
+ gridfs/grid_file.py:73: error: Missing return statement  [return]

pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/main.py:782: error: Missing return statement  [return]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/test_utils.py:611:5: error: Missing return statement  [return]
+ aiohttp/test_utils.py:611:5: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-return for more info

streamlit (https://github.com/streamlit/streamlit)
+ lib/tests/streamlit/external/langchain/capturing_callback_handler.py: note: In member "on_agent_action" of class "CapturingCallbackHandler":
+ lib/tests/streamlit/external/langchain/capturing_callback_handler.py:196:5: error: Missing return statement  [return]
+ lib/streamlit/external/langchain/streamlit_callback_handler.py: note: In member "on_agent_action" of class "StreamlitCallbackHandler":
+ lib/streamlit/external/langchain/streamlit_callback_handler.py:383:5: error: Missing return statement  [return]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/trackref.py:58: error: Missing return statement  [return]

discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/context.py:544: error: Missing return statement  [return]
+ discord/ext/commands/cooldowns.py:64: error: Missing return statement  [return]
+ discord/ext/commands/hybrid.py:133: error: Missing return statement  [return]

urllib3 (https://github.com/urllib3/urllib3)
+ test/test_wait.py:111: error: Missing return statement  [return]
+ test/test_wait.py:142: error: Missing return statement  [return]
+ test/test_wait.py:176: error: Missing return statement  [return]

@jakethesnake420
Copy link

bump this

@hauntsaninja
Copy link
Collaborator Author

I think this is too disruptive for too little benefit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a NoImplicit return type specifier.

3 participants