-
-
Couldn't load subscription status.
- Fork 29
Open
Description
Description
Currently, the extension template includes comprehensive linting and type checking for JavaScript/TypeScript (ESLint, TypeScript compiler, Prettier, Stylelint), but the Python code lacks type annotations and type checking tooling.
Proposal
Phase 1: Add Type Annotations
Add type hints to all Python code in the template:
- Function parameters and return types
- Class attributes and methods
- Use modern Python typing features (
typingmodule,Optional,Union, etc.)
Phase 2: Add Type Checker
Once type annotations are in place, add a type checker to verify them. Options:
Option 1: mypy (Community)
- Open-source type checker developed by the Python community
- De facto standard Python type checker
- Extensive configuration options
- Good for projects with gradual typing adoption
- Reference: https://github.com/python/mypy
Option 2: Ruff (Astral Software Inc.)
- Fast Python linter and formatter written in Rust
- Can replace multiple tools (flake8, black, isort, etc.)
- Growing type checking capabilities
- Single tool for multiple purposes
- Reference: https://github.com/astral-sh/ruff
Option 3: Pyright (Microsoft)
- Fast type checker from Microsoft
- Excellent IDE integration (native support in VS Code)
- Very fast and accurate
- Well-established in the ecosystem
- Reference: https://github.com/microsoft/pyright
Option 4: Pyrefly (Meta)
- Fast type checker and language server from Meta
- Ground-up rebuild (not based on Pyre)
- Combines type checking with language server features (code navigation, completion, semantic highlighting)
- Provides migration path from Pyright
- Reference: https://github.com/facebook/pyrefly
Benefits
- Type Safety: Catch type-related bugs before runtime
- Better IDE Support: Enhanced autocomplete, refactoring, and navigation
- Documentation: Types serve as inline documentation
- Consistency: Align Python code quality with existing JavaScript/TypeScript standards
- Modern Python: Follow current best practices (PEP 484+)
Implementation
- Add type annotations to all Python files in template
- Add tool dependencies to
[project.optional-dependencies]inpyproject.toml.jinja - Add tool configuration sections to
pyproject.toml.jinja - Update AGENTS.md with commands to run type checking
- Consider adding pre-commit hooks or GitHub Actions for CI
krassowski
Metadata
Metadata
Assignees
Labels
No labels