Skip to content

chore: remove duplicate imports, dead code, and pointless copies#313

Open
henryiii wants to merge 1 commit into
mainfrom
chore/simplifications
Open

chore: remove duplicate imports, dead code, and pointless copies#313
henryiii wants to merge 1 commit into
mainfrom
chore/simplifications

Conversation

@henryiii

@henryiii henryiii commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Summary

No-behavior-change cleanups identified in review:

  • Move import contextlib into the stdlib import block (was stranded after the TYPE_CHECKING block)
  • Remove duplicate import re inside the sys.version_info < (3, 12, 4) guard (re is already imported at module top)
  • Remove duplicate "KNOWN_METADATA_VERSIONS" entry in constants.__all__
  • Drop no-op os.fspath() wrapping Path.as_posix() calls — as_posix() already returns str
  • Remove trailing continue at end of loop body in _validate_dotted_names (last statement, no effect)
  • Iterate val.items() directly instead of val.copy().items() in get_optional_dependencies; return requirements_dict directly instead of dict(requirements_dict)
  • Remove redundant assert "project" in data — the block above already raised if "project" was missing; mypy passes without it
  • Simplify KeyDispatcher.dispatch from a list-build + index + dict-lookup to a single next() expression

Test plan

  • prek -a --quiet — lint passes
  • uv run noxfile.py -s mypy — mypy strict passes (252 sources, no issues)
  • uv run pytest — 252 passed, 83 skipped (exceptiongroup not installed)

🤖 Generated with Claude Code

Part of #307.

@henryiii henryiii force-pushed the chore/simplifications branch from de1eb4c to 10e367c Compare June 16, 2026 04:14
- Move `import contextlib` into the stdlib import block
- Remove duplicate `import re` inside the `sys.version_info` guard
- Remove duplicate `"KNOWN_METADATA_VERSIONS"` entry in `constants.__all__`
- Drop no-op `os.fspath()` around `Path.as_posix()` (already returns str)
- Remove trailing `continue` at end of loop body in `_validate_dotted_names`
- Iterate `val.items()` directly instead of `val.copy().items()` in
  `get_optional_dependencies`; return `requirements_dict` directly
- Remove redundant `assert "project" in data` (block above already raised)
- Simplify `KeyDispatcher.dispatch` to a single `next()` expression

Assisted-by: ClaudeCode:claude-sonnet-4-6
@henryiii henryiii force-pushed the chore/simplifications branch from 10e367c to a62e211 Compare June 16, 2026 04:57
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.

1 participant