style: enable ruff ANN rule for type annotations#98
Conversation
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #98 +/- ##
==========================================
- Coverage 74.34% 74.32% -0.03%
==========================================
Files 9 9
Lines 807 810 +3
==========================================
+ Hits 600 602 +2
- Misses 207 208 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot Run pipx run uv tool run --with .[typecheck] basedpyright |
There was a problem hiding this comment.
Pull request overview
This PR enables the flake8-annotations (ANN) rule in ruff to enforce type annotations across the entire dargs codebase. The changes add return type and parameter type annotations to approximately 170 functions while preserving legitimate uses of Any for the library's dynamic type handling needs.
Changes:
- Enabled ANN rule in ruff configuration with ANN401 (any-type) exception and allow-star-arg-any setting
- Added comprehensive type annotations to core library modules (dargs.py, cli.py, sphinx.py, notebook.py)
- Added type annotations to all test methods and test helper functions
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added ANN to ruff select list, ignored ANN401 for Any usage, enabled allow-star-arg-any configuration |
| dargs/dargs.py | Added return types and parameter types to ~60 methods including Argument/Variant classes and utility functions |
| dargs/cli.py | Added type annotations to CLI entry points and command functions |
| dargs/sphinx.py | Added type annotations to Sphinx directive and domain classes |
| dargs/notebook.py | Added type annotations to Jupyter notebook display functions and ArgumentData class |
| docs/conf.py | Added type annotations to Sphinx setup and apidoc functions |
| tests/dpmdargs.py | Added type annotations to ~40 test helper functions that generate argument structures |
| tests/test_checker.py | Added -> None return type to all test methods |
| tests/test_cli.py | Added -> None return type to all test methods |
| tests/test_creation.py | Added -> None return type to all test methods |
| tests/test_docgen.py | Added -> None return type to all test methods |
| tests/test_json_schema.py | Added -> None return type to all test methods |
| tests/test_normalizer.py | Added -> None return type to all test methods and helper function |
| tests/test_notebook.py | Added -> None return type to test method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix _DUMMYHOOK to accept Argument | Variant for first parameter - Fix gen_doc_head to handle None path when make_anchor is True - Fix _get_type_name to handle None value properly Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Fixed the basedpyright type errors in commit f4dba3d:
All tests pass (34 passed, 1 skipped). |
Enable ruff rule ANN
Plan to enable the ANN (type annotations) rule in ruff configuration and fix all violations:
Summary
Successfully enabled the ANN (flake8-annotations) rule in ruff configuration. Added type annotations to 170+ functions and parameters across the codebase. All tests pass and ruff checks pass with zero errors. Fixed basedpyright type checking errors.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.