Skip to content

Add type annotations to resolve ty type checker issues#117

Merged
bittner merged 1 commit intofeature/use-ty-insteadof-mypyfrom
copilot/sub-pr-116
Jan 10, 2026
Merged

Add type annotations to resolve ty type checker issues#117
bittner merged 1 commit intofeature/use-ty-insteadof-mypyfrom
copilot/sub-pr-116

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

The ty type checker flagged 20 type errors in the codebase, primarily in CleanupRunner class attributes and usage patterns.

Changes

pyclean/runner.py

  • Added type annotations to CleanupRunner attributes: Callable[[Path], None] for methods, list[str] for ignore patterns, int for counters
  • Annotated configure(args: argparse.Namespace) -> None parameter
  • Initialized callable attributes with placeholder functions instead of None to eliminate union types

pyclean/traversal.py

  • Updated should_ignore() signature to accept list[str] | None for ignore_patterns, matching runtime behavior where None is handled via early return

tests/test_traversal.py

  • Fixed test calls to should_ignore() to pass str instead of Path objects

Before/After

# Before: ty complained about None unions
class CleanupRunner:
    def __init__(self):
        self.unlink = None  # Type: None, but later assigned callable
        self.ignore = None  # Type: None, but later assigned list
        
# After: explicit types, no unions
class CleanupRunner:
    def __init__(self):
        self.unlink: Callable[[Path], None] = _noop_file
        self.ignore: list[str] = []

All 20 type errors resolved. Type checking now passes cleanly with ty check.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update type checking to use ty instead of MyPy Add type annotations to resolve ty type checker issues Jan 9, 2026
Copilot AI requested a review from bittner January 9, 2026 23:53
@bittner bittner marked this pull request as ready for review January 10, 2026 16:08
@bittner bittner force-pushed the copilot/sub-pr-116 branch from a51093b to 2813335 Compare January 10, 2026 16:49
Co-authored-by: bittner <665072+bittner@users.noreply.github.com>
@bittner bittner force-pushed the copilot/sub-pr-116 branch from 2813335 to b75d68b Compare January 10, 2026 16:50
@bittner bittner merged commit 169b38a into feature/use-ty-insteadof-mypy Jan 10, 2026
1 check passed
@bittner bittner deleted the copilot/sub-pr-116 branch January 10, 2026 16:53
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