Skip to content

Commit 67244e8

Browse files
dguidoclaude
andcommitted
refactor: replace ty with pyright and improve configurations
- Replace experimental ty (0.0.1a16) with stable pyright (1.1+) - Configure pyright with standard type checking mode - Make pre-commit pytest less aggressive: only run fast tests (-k "not slow") - Remove -q flag from pytest for better debugging visibility - Clarify CLAUDE.md framework preferences as general guidelines - Add missing newline to pre-commit config - Update all references from ty to pyright in docs and commands This makes the type checking more reliable while maintaining the same strict code quality standards. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2902ab9 commit 67244e8

4 files changed

Lines changed: 30 additions & 22 deletions

File tree

{{cookiecutter.project_slug}}/.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ repos:
1212

1313
- repo: local
1414
hooks:
15-
- id: ty
16-
name: ty type check
17-
entry: uv run ty check src
15+
- id: pyright
16+
name: pyright type check
17+
entry: uv run pyright
1818
language: system
1919
types: [python]
2020
pass_filenames: false
@@ -30,8 +30,8 @@ repos:
3030
{%- endif %}
3131

3232
- id: pytest
33-
name: pytest
34-
entry: uv run pytest -q
33+
name: pytest (fast tests only)
34+
entry: uv run pytest -x --tb=short -k "not slow"
3535
language: system
3636
types: [python]
3737
pass_filenames: false
@@ -42,4 +42,4 @@ repos:
4242
# Configuration
4343
ci:
4444
autofix_prs: true
45-
autoupdate_schedule: weekly
45+
autoupdate_schedule: weekly

{{cookiecutter.project_slug}}/CLAUDE.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ make dev
3333
make check # Runs lint + tests
3434

3535
# Code quality
36-
make lint # ruff format --check + ruff check + ty check
36+
make lint # ruff format --check + ruff check + pyright
3737
make fix # Auto-fix formatting and lint issues
38-
make ty # Run type checker
38+
make typecheck # Run pyright type checker
3939

4040
# Testing
4141
make test # Run pytest with coverage
@@ -65,11 +65,14 @@ test/
6565
6666
Tests can also live beside source files as `test_*.py` or `*_test.py`.
6767
68-
## Framework Preferences
68+
## General Python Guidelines
6969
70-
- **Web**: Always use FastAPI, never Flask
71-
- **Data**: Prefer Polars over Pandas for new code
72-
- **Async**: Use native async/await, not threading
70+
These are general preferences for Python development:
71+
72+
- **Web frameworks**: Prefer FastAPI over Flask for new projects
73+
- **Data processing**: Consider Polars for performance-critical data operations
74+
- **Async programming**: Use native async/await instead of threading
75+
- **Type checking**: Always use type hints and run pyright
7376
7477
## Common Patterns
7578
@@ -123,7 +126,7 @@ parser.add_argument(
123126
## CI/CD
124127
125128
GitHub Actions run on every push/PR:
126-
1. **Linting**: ruff format/check + ty type checking
129+
1. **Linting**: ruff format/check + pyright type checking
127130
2. **Tests**: pytest with coverage
128131
3. **Security**: zizmor workflow scanning
129132
{%- if cookiecutter.documentation == "pdoc" %}
@@ -134,7 +137,7 @@ GitHub Actions run on every push/PR:
134137
135138
1. **Never commit code that violates the quality standards** - refactor instead
136139
2. **All public APIs need Google-style docstrings**
137-
3. **Type hints are mandatory** - use `ty check`
140+
3. **Type hints are mandatory** - use `pyright`
138141
4. **Tests can live beside code** - prefer colocated tests for better maintainability
139142
140143
## Project-Specific Instructions

{{cookiecutter.project_slug}}/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ $(VENV)/pyvenv.cfg: pyproject.toml
6060
lint: $(VENV)/pyvenv.cfg
6161
uv run ruff format --check && \
6262
uv run ruff check && \
63-
uv run ty check src
63+
uv run pyright
6464

6565
{%- if cookiecutter.docstring_coverage %}
6666
uv run interrogate -c pyproject.toml .
@@ -69,9 +69,9 @@ lint: $(VENV)/pyvenv.cfg
6969
.PHONY: check
7070
check: lint test
7171

72-
.PHONY: typecheck ty
73-
typecheck ty: $(VENV)/pyvenv.cfg
74-
uv run ty check src
72+
.PHONY: typecheck
73+
typecheck: $(VENV)/pyvenv.cfg
74+
uv run pyright
7575

7676
.PHONY: fix format reformat
7777
fix format reformat:
@@ -80,7 +80,7 @@ fix format reformat:
8080

8181
.PHONY: test tests
8282
test tests: $(VENV)/pyvenv.cfg
83-
uv run pytest -q --cov=$(PY_IMPORT) $(T) $(TEST_ARGS)
83+
uv run pytest --cov=$(PY_IMPORT) $(T) $(TEST_ARGS)
8484
uv run coverage report -m $(COV_ARGS)
8585

8686
.PHONY: doc

{{cookiecutter.project_slug}}/pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ lint = [
3434
# NOTE: ruff is under active development, so we pin conservatively here
3535
# and let Dependabot periodically perform this update.
3636
"ruff ~= 0.6.2",
37-
"ty >= 0.0.1a16",
37+
"pyright >= 1.1",
3838
"types-html5lib",
3939
"types-requests",
4040
"types-toml",
@@ -59,7 +59,12 @@ Source = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.
5959
# don't attempt code coverage for the CLI entrypoints
6060
omit = ["{{ cookiecutter.__project_src_path }}/_cli.py"]
6161

62-
# ty configuration - using defaults for now as ty is in early alpha
62+
[tool.pyright]
63+
# Type checking configuration
64+
pythonVersion = "3.11"
65+
typeCheckingMode = "standard"
66+
useLibraryCodeForTypes = true
67+
reportMissingTypeStubs = false
6368

6469
[tool.ruff]
6570
line-length = 100
@@ -121,4 +126,4 @@ fail-under = 100
121126
testpaths = ["src", "test"]
122127
python_files = ["test_*.py", "*_test.py"]
123128
# Show test durations
124-
addopts = "-q --durations=10"
129+
addopts = "--durations=10"

0 commit comments

Comments
 (0)