Skip to content

Conversation

@A5rocks
Copy link
Collaborator

@A5rocks A5rocks commented Dec 16, 2025

Fixes #20408

This is a draft PR because:

  • it doesn't work with dmypy
  • it's a bit slower:
=== Results ===

master                    2.697s (0.0%) | stdev 0.012s
f18e550f23d30c454a0f6fc2c8b41eb9e03b4f29 2.732s (+1.3%) | stdev 0.018s

@A5rocks
Copy link
Collaborator Author

A5rocks commented Dec 16, 2025

Idea for a speedup (so I don't forget): only do this for things that can be skipped unreachable (I.e. stmts in a block, toplevel stmts).

Also note that I haven't cleaned this up, which would involve removing eg the assert False special case and adding a test case for the issue this fixes.

@github-actions
Copy link
Contributor

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

comtypes (https://github.com/enthought/comtypes)
- comtypes/test/test_server.py:326: error: Module "comtypes.gen" has no attribute "TestLib"  [attr-defined]

egglog-python (https://github.com/egraphs-good/egglog-python)
+ python/tests/test_unstable_fn.py:177: error: Unused "type: ignore" comment  [unused-ignore]

Expression (https://github.com/cognitedata/Expression)
- README.py:498: error: Name "z" already defined on line 496  [no-redef]
- README.py:572: error: Name "z" already defined on line 570  [no-redef]
- README.py:628: error: Name "xs" already defined on line 211  [no-redef]
- README.py:632: error: Name "mapper" already defined on line 207  [no-redef]
- README.py:633: error: Name "predicate" already defined on line 208  [no-redef]
- README.py:634: error: Name "folder" already defined on line 209  [no-redef]

AutoSplit (https://github.com/Toufool/AutoSplit)
- src/utils.py:147:12: error: Name "win32ui" is not defined  [name-defined]
- src/utils.py:155:29: error: Name "ctypes" is not defined  [name-defined]
- src/utils.py:156:5: error: Name "ctypes" is not defined  [name-defined]
- src/utils.py:159:9: error: Name "ctypes" is not defined  [name-defined]
- src/utils.py:160:9: error: Name "ctypes" is not defined  [name-defined]
- src/utils.py:163:19: error: Name "win32gui" is not defined  [name-defined]
- src/utils.py:176:20: error: Name "FilterGraph" is not defined  [name-defined]
- src/utils.py:182:12: error: Name "COMError" is not defined  [name-defined]

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.

unexpected attr-defined error in imports in dead code

1 participant