Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 4 additions & 45 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Project Overview

This is a template Python repository demonstrating modern Python tooling with `uv`, `ruff`, `mypy`, and `pytest`. The project uses Python 3.13+ and follows strict type checking and linting standards. It includes an example package with a console entry point, build configuration using hatchling, and comprehensive CI/CD pipelines.
This is a template Python repository demonstrating modern Python tooling with `uv`, `ruff`, `ty`, and `pytest`. The project uses Python 3.13+ and follows strict type checking and linting standards. It includes an example package with a console entry point, build configuration using hatchling, and comprehensive CI/CD pipelines.

## Package Management with uv

- **Always use `uv` commands**, not `pip` - this project is managed exclusively with `uv`
- Install dependencies: `uv sync` (core) or `uv sync --extra dev` (with dev tools)
- Run commands: `uv run <command>` (e.g., `uv run pytest`, `uv run mypy .`)
- Run commands: `uv run <command>` (e.g., `uv run pytest`, `uv run ty check .`)
- Update dependencies: `uv lock --upgrade`
- Version pinned in `.python-version` (currently 3.13)

Expand All @@ -23,10 +23,8 @@ This is a template Python repository demonstrating modern Python tooling with `u
- **Ignored rules**: D203, D213 (conflicting docstring rules), PLR0913 (too many arguments), S101 (assert allowed in tests)
- `__init__.py` files excluded from linting via `extend-exclude`

### Type Checking (mypy)
### Type Checking (ty)

- Strict configuration: `disallow_incomplete_defs`, `check_untyped_defs`, `warn_return_any`, `warn_redundant_casts`, `warn_unused_ignores`, `warn_unreachable`
- NumPy imports ignore missing type stubs via `[[tool.mypy.overrides]]`
- **All functions require type annotations** - never omit return types or parameter types

### Testing (pytest)
Expand All @@ -47,51 +45,13 @@ This is a template Python repository demonstrating modern Python tooling with `u

## Development Workflow

### Pre-commit Hooks

- **Install hooks**: `uv run pre-commit install` (run once after cloning)
- Hooks run automatically on `git commit` and check:
- Ruff formatting and linting (with auto-fix)
- mypy type checking
- Trailing whitespace, YAML syntax, TOML syntax
- Merge conflicts and large files
- **Run manually**: `uv run pre-commit run --all-files`
- Configuration in `.pre-commit-config.yaml`

### Before Committing

1. Format: `uv run ruff format .`
2. Lint: `uv run ruff check .`
3. Type check: `uv run mypy .`
3. Type check: `uv run ty check .`
4. Test: `uv run pytest`

### CI Pipeline (.github/workflows/ci.yml)

The CI runs 7 jobs in parallel:

1. `validate-pyproject` - validates pyproject.toml structure with `validate-pyproject`
2. `ruff` - linting with `uv run -m ruff check`
3. `mypy` - type checking with `uv run -m mypy .`
4. `test` - pytest with HTML coverage report (uploaded as artifact), fails if coverage < 80%
5. `bandit` - security scanning for Python code vulnerabilities
6. `pip-audit` - dependency vulnerability scanning
7. `version-check` - ensures version consistency between `pyproject.toml` and `uv.lock`

**Note**: CI uses custom composite actions in `.github/actions/` for environment setup:

- `setup-python-dev` - installs Python + uv + dev dependencies
- `setup-python-core` - installs Python + uv + core dependencies only

## Build Pipeline (.github/workflows/build.yml)

The Build workflow runs on pushes and pull requests to the `main` branch.
It consists of the following jobs:

1. `build_wheel` - builds the wheel using `uv build`, inspects contents, and uploads as artifact
2. `verify_structure` - downloads the wheel, installs it, and verifies the installed package structure

**Note**: Uses hatchling as the build backend, configured in `pyproject.toml` under `[tool.hatch.build]`

## Code Style Patterns

### Module Documentation
Expand Down Expand Up @@ -129,7 +89,6 @@ def test_example_function() -> None:
- `docs/` - documentation files
- `template_python/` - main package code
- `tests/` - pytest test files
- `.pre-commit-config.yaml` - pre-commit hook configuration
- `.python-version` - Python version specification for `uv` and CI
- `pyproject.toml` - single source of truth for all configuration (build, dependencies, tooling)
- `uv.lock` - locked dependency versions
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- uses: actions/checkout@v6
- uses: javidahmed64592/actions-template-python/actions/ci/ruff@main

mypy:
ty:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: javidahmed64592/actions-template-python/actions/ci/mypy@main
- uses: javidahmed64592/actions-template-python/actions/ci/ty@main

pytest:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions docs/source/smg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Backend (Python)
:target: https://github.com/astral-sh/ruff
:alt: Ruff

.. image:: https://img.shields.io/badge/mypy-Latest-2A6DB2?style=flat-square
:target: https://mypy.readthedocs.io/
:alt: Mypy
.. image:: https://img.shields.io/badge/ty-Latest-2A6DB2?style=flat-square
:target: https://astral.sh/blog/ty
:alt: Ty

.. image:: https://img.shields.io/badge/Sphinx-Latest-000000?style=flat-square&logo=sphinx&logoColor=white
:target: https://www.sphinx-doc.org/
Expand Down Expand Up @@ -57,7 +57,7 @@ Testing, Linting, and Type Checking
uv run ruff format .

# Type check
uv run mypy .
uv run ty check .

# Run tests
uv run pytest
Expand Down
18 changes: 1 addition & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ dependencies = [
[project.optional-dependencies]
dev = [
"bandit>=1.9.4",
"mypy>=2.1.0",
"pip-audit>=2.10.0",
"pytest>=9.0.3",
"pytest-cov>=7.1.0",
"ruff>=0.15.13",
"ty>=0.0.43",
"validate-pyproject>=0.25.0",
]
docs = [
Expand Down Expand Up @@ -163,19 +163,3 @@ line-ending = "auto"

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.mypy]
warn_unused_configs = true
disallow_incomplete_defs = true
check_untyped_defs = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
warn_unreachable = true
pretty = true

[[tool.mypy.overrides]]
module = [
"pyhere.*"
]
ignore_missing_imports = true
Loading
Loading