Skip to content

Dedicated error code for explicit any#18398

Merged
hauntsaninja merged 1 commit into
python:masterfrom
hauntsaninja:explicit-any
Jan 6, 2025
Merged

Dedicated error code for explicit any#18398
hauntsaninja merged 1 commit into
python:masterfrom
hauntsaninja:explicit-any

Conversation

@hauntsaninja

Copy link
Copy Markdown
Collaborator

No description provided.


.. _code-narrowed-type-not-subtype:

Check that ``TypeIs`` narrows types [narrowed-type-not-subtype]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this is on by default, so moving it to the correct page while i'm here

@github-actions

github-actions Bot commented Jan 1, 2025

Copy link
Copy Markdown
Contributor

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

trio (https://github.com/python-trio/trio)
+ src/trio/_core/_thread_cache.py:219: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_thread_cache.py:219: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_thread_cache.py:219: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_util.py:24: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_util.py:24: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_util.py:24: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_util.py:181: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_util.py:181: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_util.py:181: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_util.py:189: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_util.py:189: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_util.py:189: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_util.py:253: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_util.py:253: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_util.py:253: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_util.py:350: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_util.py:350: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_util.py:350: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_util.py:353: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_util.py:353: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_util.py:353: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_highlevel_serve_listeners.py:29: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_highlevel_serve_listeners.py:29: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_highlevel_serve_listeners.py:29: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_highlevel_serve_listeners.py:72: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_highlevel_serve_listeners.py:72: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_highlevel_serve_listeners.py:72: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_traps.py:108: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_traps.py:108: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_traps.py:108: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_socket.py:50: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_socket.py:50: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_socket.py:50: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_instrumentation.py:15: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_instrumentation.py:15: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_instrumentation.py:15: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_instrumentation.py:21: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_instrumentation.py:21: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_instrumentation.py:21: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_file_io.py:431: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_file_io.py:431: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_entry_queue.py:20: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_entry_queue.py:20: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_entry_queue.py:20: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_ssl.py:427: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_ssl.py:427: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_ssl.py:427: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_highlevel_open_tcp_stream.py:138: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_highlevel_open_tcp_stream.py:138: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_highlevel_open_tcp_stream.py:138: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1291: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1291: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1291: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1391: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1391: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1391: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1394: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1394: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1394: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1413: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1413: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1413: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1414: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1414: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1414: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1416: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1416: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1416: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1484: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1484: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1484: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1630: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1630: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1630: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1635: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1635: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1635: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1638: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1638: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1638: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1684: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1684: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:1684: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1693: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:1693: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:1693: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:2121: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:2121: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:2121: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_run.py:2423: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_run.py:2423: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_run.py:2423: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:150: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:150: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:150: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_threads.py:151: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_threads.py:151: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:151: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:210: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:210: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:210: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_threads.py:211: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_threads.py:211: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:211: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:255: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:255: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:528: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_threads.py:528: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:528: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_threads.py:573: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_threads.py:573: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_threads.py:573: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_path.py:34: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_path.py:34: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_path.py:34: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_path.py:187: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_path.py:187: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_path.py:197: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/testing/_fake_net.py:511: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/testing/_fake_net.py:511: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/testing/_fake_net.py:511: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_tests/test_subprocess.py:86: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_tests/test_subprocess.py:99: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_tests/test_subprocess.py:119: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_subprocess.py:119: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_tests/test_subprocess.py:119: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_tests/test_ssl.py:385: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_ssl.py:385: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_tests/test_ssl.py:385: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_tests/test_run.py:1662: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_tests/test_run.py:1662: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_tests/test_run.py:1662: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_tests/test_run.py:1700: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_tests/test_run.py:1700: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_tests/test_run.py:1700: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_tests/test_run.py:1706: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_tests/test_run.py:1706: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_tests/test_run.py:1706: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_core/_tests/test_ki.py:681: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_tests/test_ki.py:681: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_core/_tests/test_ki.py:681: note: Error code "explicit-any" not covered by "type: ignore" comment
+ src/trio/_tests/test_threads.py:59: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_threads.py:59: error: Explicit "Any" is not allowed  [explicit-any]
+ src/trio/_tests/test_threads.py:59: note: Error code "explicit-any" not covered by "type: ignore" comment

@A5rocks

A5rocks commented Jan 1, 2025

Copy link
Copy Markdown
Collaborator

I know the diff for trio looks bad, but we're already generally writing out explanations for this so this change is good:

https://github.com/python-trio/trio/blob/7084b564ea6780aa144cdb08fc85bf1cc9e703e0/src/trio/_util.py#L23-L24

-snip, I misread a note as an error-

@hauntsaninja

Copy link
Copy Markdown
Collaborator Author

Yup, I got here because I realised I could batch some type ignore thrash for trio here: #18397 (comment)

@hauntsaninja hauntsaninja merged commit b96a3f1 into python:master Jan 6, 2025
@hauntsaninja hauntsaninja deleted the explicit-any branch January 6, 2025 20:21
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.

2 participants