Skip to content

Improve code quality with type hints, docstrings, and linting - #23

Merged
knifflig merged 10 commits into
mainfrom
claude/fix-github-workflow-KPx2I
Mar 18, 2026
Merged

knifflig merged 10 commits into
mainfrom
claude/fix-github-workflow-KPx2I

Conversation

@knifflig

Copy link
Copy Markdown
Owner

Summary

This PR improves overall code quality through comprehensive type annotations, docstring additions, and code style improvements across the codebase. The changes focus on enhancing maintainability and consistency without altering functionality.

Key Changes

Type Annotations & Imports

  • Added explicit type hints to function signatures throughout the codebase (parameters and return types)
  • Replaced Any imports with specific types or TYPE_CHECKING guards where appropriate
  • Added Generator, Iterator, Callable, and other collections.abc imports for better type specificity
  • Implemented TYPE_CHECKING blocks to avoid circular imports while maintaining type safety

Docstrings

  • Added module-level docstrings to all test __init__.py files
  • Added class-level docstrings to test classes (e.g., """Tests for TestStatusCommand.""")
  • Added method-level docstrings to test methods and helper functions
  • Improved docstring consistency and clarity across the codebase

Code Style & Formatting

  • Fixed quote consistency in test files (single vs double quotes)
  • Improved line wrapping and formatting for better readability
  • Added blank lines between class definitions and methods where appropriate
  • Reformatted multi-line function calls and definitions for consistency

Infrastructure

  • Added ruff>=0.11.0 to dev dependencies for linting support
  • Updated GitHub Actions workflows for proper virtual environment handling

Notable Implementation Details

  • Type hints use modern Python syntax (e.g., str | None instead of Optional[str])
  • Lazy imports via TYPE_CHECKING prevent circular dependencies while preserving IDE support
  • Docstrings follow consistent format with brief descriptions and parameter documentation
  • All changes are backward compatible with no functional modifications

https://claude.ai/code/session_01Mh9N715DtHCyzoUDicjVea

claude and others added 9 commits March 18, 2026 08:30
uv venv does not install pip into the virtualenv. Use `VIRTUAL_ENV=... uv pip install`
to install the wheel into the smoke-test venv.

https://claude.ai/code/session_01Mh9N715DtHCyzoUDicjVea
The heredoc body (<!DOCTYPE html>...) had no indentation, breaking out of
the YAML block scalar which requires consistent indentation. Replace with
a single printf call.

https://claude.ai/code/session_01Mh9N715DtHCyzoUDicjVea
The CI lint step runs `uv run ruff check` but ruff was not listed in
the dependency-groups.dev section of pyproject.toml, causing the command
to fail with "No such file or directory".

https://claude.ai/code/session_01Mh9N715DtHCyzoUDicjVea
Add type annotations, docstrings, and fix lint issues to satisfy the
strict ruff configuration (ANN, D, E, F, B, I, UP, W rules). All 2895
errors resolved with zero regressions (1021 tests pass).

Key changes:
- Add missing type annotations (ANN001/ANN201/ANN202/ANN204/ANN205)
- Replace Any with concrete types where possible (ANN401)
- Add docstrings to all public classes, methods, functions, packages
- Fix undefined names (F821) by adding missing imports
- Fix line-too-long (E501), unused variables (F841)
- Add noqa comments for intentionally deferred imports (E402)
- Fix raise-without-from (B904), unused loop vars (B007)
- Auto-format with ruff format

https://claude.ai/code/session_01Mh9N715DtHCyzoUDicjVea
Rich/typer renders ANSI escape codes in help output that differ between
Python versions. Strip ANSI codes before asserting on flag presence in
help text.

https://claude.ai/code/session_01Mh9N715DtHCyzoUDicjVea
@knifflig
knifflig merged commit b74a2a3 into main Mar 18, 2026
11 checks passed
@knifflig
knifflig deleted the claude/fix-github-workflow-KPx2I branch March 18, 2026 13:18
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