-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use a dedicated error code for assignment to method #14570
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think that this would be good to have, since several projects are impacted by the change otherwise. After 1.0 release we want to avoid regressions whenever it's not too difficult. |
This comment has been minimized.
This comment has been minimized.
Looks like the unused ignore logic also needs some futzing |
After some thinking, IMO people who use |
flake8-pyi is one of the affected projects here in the mypy_primer diff, and I agree that I'd very much want to see these errors (as a maintainer of that project). This seems like a great solution to me. |
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
- src/pip/_internal/network/session.py:246: error: Cannot assign to a method [assignment]
+ src/pip/_internal/network/session.py:246: error: Cannot assign to a method [method-assign]
flake8-pyi (https://github.com/PyCQA/flake8-pyi)
+ pyi.py:215: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ pyi.py:217: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/protobufs/msg.py:125: error: Cannot assign to a method [assignment]
+ steam/protobufs/msg.py:125: error: Cannot assign to a method [method-assign]
pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/vendor/decorator.py:295: error: Cannot assign to a method [assignment]
+ pyinstrument/vendor/decorator.py:295: error: Cannot assign to a method [method-assign]
- pyinstrument/vendor/decorator.py:301: error: Cannot assign to a method [assignment]
+ pyinstrument/vendor/decorator.py:301: error: Cannot assign to a method [method-assign]
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/docutils.py:220: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ sphinx/util/docutils.py:221: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ sphinx/util/docutils.py:227: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ sphinx/util/docutils.py:228: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
core (https://github.com/home-assistant/core)
+ homeassistant/block_async_io.py:11: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ homeassistant/runner.py:76: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ homeassistant/helpers/schema_config_entry_flow.py:278: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
dragonchain (https://github.com/dragonchain/dragonchain)
- dragonchain/lib/dto/eth_utest.py:51:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:51:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/eth_utest.py:72:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:72:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/eth_utest.py:77:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:77:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/eth_utest.py:88:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:88:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/eth_utest.py:115:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:115:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/eth_utest.py:123:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:123:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/eth_utest.py:131:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/eth_utest.py:131:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:51:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:51:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:56:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:56:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:61:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:61:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:62:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:62:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:70:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:70:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:77:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:77:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:84:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:84:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:90:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:90:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:101:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:101:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:108:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:108:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:114:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:114:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:120:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:120:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:125:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:125:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:131:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:131:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/btc_utest.py:138:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/btc_utest.py:138:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:73:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:73:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:78:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:78:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:84:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:84:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:109:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:109:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:118:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:118:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:119:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:119:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:122:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:122:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:123:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:123:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:131:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:131:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:140:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:140:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:149:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:149:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:156:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:156:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:164:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:164:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:170:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:170:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:173:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:173:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:180:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:180:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:183:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:183:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:192:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:192:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:322:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:322:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:331:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:331:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:338:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:338:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:339:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:339:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:347:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:347:9: error: Cannot assign to a method [method-assign]
- dragonchain/lib/dto/bnb_utest.py:349:9: error: Cannot assign to a method [assignment]
+ dragonchain/lib/dto/bnb_utest.py:349:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:238:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:238:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:239:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:239:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:466:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:466:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:467:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:467:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:481:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:481:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:482:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:482:9: error: Cannot assign to a method [method-assign]
- dragonchain/transaction_processor/level_5_actions_utest.py:493:9: error: Cannot assign to a method [assignment]
+ dragonchain/transaction_processor/level_5_actions_utest.py:493:9: error: Cannot assign to a method [method-assign]
... (truncated 84 lines) ...
spark (https://github.com/apache/spark)
+ python/pyspark/sql/session.py:115: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ python/pyspark/pandas/frame.py:12100: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
+ python/pyspark/pandas/frame.py:12113: error: Unused "type: ignore" comment, use narrower [method-assign] instead of [assignment]
discord.py (https://github.com/Rapptz/discord.py)
- discord/file.py:106: error: Cannot assign to a method [assignment]
+ discord/file.py:106: error: Cannot assign to a method [method-assign]
- discord/file.py:146: error: Cannot assign to a method [assignment]
+ discord/file.py:146: error: Cannot assign to a method [method-assign]
- discord/gateway.py:391: error: Cannot assign to a method [assignment]
+ discord/gateway.py:391: error: Cannot assign to a method [method-assign]
- discord/gateway.py:392: error: Cannot assign to a method [assignment]
+ discord/gateway.py:392: error: Cannot assign to a method [method-assign]
- discord/gateway.py:830: error: Cannot assign to a method [assignment]
+ discord/gateway.py:830: error: Cannot assign to a method [method-assign]
- discord/state.py:253: error: Cannot assign to a method [assignment]
+ discord/state.py:253: error: Cannot assign to a method [method-assign]
- discord/ui/view.py:175: error: Cannot assign to a method [assignment]
+ discord/ui/view.py:175: error: Cannot assign to a method [method-assign]
- discord/app_commands/tree.py:828: error: Cannot assign to a method [assignment]
+ discord/app_commands/tree.py:828: error: Cannot assign to a method [method-assign]
- discord/app_commands/commands.py:1807: error: Cannot assign to a method [assignment]
+ discord/app_commands/commands.py:1807: error: Cannot assign to a method [method-assign]
- discord/ext/commands/help.py:278: error: Cannot assign to a method [assignment]
+ discord/ext/commands/help.py:278: error: Cannot assign to a method [method-assign]
- discord/ext/commands/help.py:279: error: Cannot assign to a method [assignment]
+ discord/ext/commands/help.py:279: error: Cannot assign to a method [method-assign]
- discord/ext/tasks/__init__.py:289: error: Cannot assign to a method [assignment]
+ discord/ext/tasks/__init__.py:289: error: Cannot assign to a method [method-assign]
streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:297:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:297:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/media_file_manager_test.py:152:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/media_file_manager_test.py:152:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/media_file_manager_test.py:191:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/media_file_manager_test.py:191:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/media_file_manager_test.py:300:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/media_file_manager_test.py:300:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/media_file_manager_test.py:321:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/media_file_manager_test.py:321:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/app_session_test.py:310:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/app_session_test.py:310:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/app_session_test.py:322:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/app_session_test.py:322:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/app_session_test.py:565:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/app_session_test.py:565:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/legacy_caching/hashing_test.py:68:5: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/legacy_caching/hashing_test.py:68:5: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:124:13: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:124:13: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:129:13: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:129:13: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:159:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:159:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:202:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:202:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:208:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:208:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:228:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:228:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:231:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:231:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/web/server/server_test.py:399:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/web/server/server_test.py:399:9: error: Cannot assign to a method [method-assign]
- lib/tests/streamlit/web/server/server_test.py:442:9: error: Cannot assign to a method [assignment]
+ lib/tests/streamlit/web/server/server_test.py:442:9: error: Cannot assign to a method [method-assign]
|
@hauntsaninja @JukkaL any more comments on this one? |
Looks good to me! |
Resolves #9789 Users could use `--disable-error-code=import-untyped` to only ignore errors about libraries not having stubs, but continue to get errors about e.g. typos in an import name. The error subcode mechanism is new from #14570. Note that users will now get a different error code depending on whether or not a package is installed, and may not know that they can use the parent error code to ignore the issue regardless. I think this is okay, in general type checking results can change if you run them in two different environments. Note also that with `--warn-unused-ignore` / `--strict` mypy will complain about not having the most specific error code
Fixes #2427
If this will cause a too big fallout, we may need to add some special logic, so that
type: ignore[assignment]
will cover[method-assign]
.