Skip to content

Instantly share code, notes, and snippets.

@frgomes
Last active September 19, 2025 11:11
Show Gist options
  • Save frgomes/c4b7a8f2e2b97f6d2fb2eb4a25205173 to your computer and use it in GitHub Desktop.
Save frgomes/c4b7a8f2e2b97f6d2fb2eb4a25205173 to your computer and use it in GitHub Desktop.
python :: pyproject.toml - template with static compilation and other lint checks
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-project"
dynamic = ["version"]
description = "Your friendly assistant"
readme = "README.md"
requires-python = ">=3.12"
license = "MIT"
keywords = []
authors = [
{ name = "Richard Gomes", email = "[email protected]" }
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"python-dotenv>=1.1.1",
"fastapi>=0.116.0",
"uvicorn>=0.35",
]
[project.urls]
Documentation = "https://github.com/myorg/my-project#readme"
Issues = "https://github.com/myorg/my-project/issues"
Source = "https://github.com/myorg/my-project"
[tool.hatch.version]
path = "src/my_project/__about__.py"
[tool.hatch.envs.default]
dependencies = [
"python-dotenv>=1.1.1",
"fastapi>=0.116.0",
"uvicorn>=0.35",
]
[tool.hatch.envs.default.scripts]
info = "echo $VIRTUAL_ENV"
serve = "uvicorn src.my_project.__main__:app --reload" ##FIXME: review
[tool.hatch.envs.lint]
detached = true
dependencies = [
"python-dotenv>=1.1.1",
"fastapi>=0.116.0",
"uvicorn>=0.35",
#--
"pyre-check",
"ruff",
"coverage[toml]",
"pytest",
"pytest-cov",
]
[tool.hatch.envs.lint.scripts]
check = "ruff check ."
style = "ruff check . --fix"
format = "ruff format ."
types = "python -c \"import site; print(site.getsitepackages()[0])\" | xargs pyre --search-path"
test = "PYTHONPATH=src pytest --cov=my_project --cov-report=term-missing"
cov = [
"PYTHONPATH=src coverage run -m pytest",
"coverage report",
"coverage html"
]
[tool.hatch.envs.test]
description = """Run the test suite."""
dependencies = [
"pytest",
"pytest-cov",
"pytest-raises",
"pytest-randomly",
"pytest-xdist",
]
[[tool.hatch.envs.test.matrix]]
python = ["3.12"]
[tool.pyre]
source_directories = ["src", "tests"]
strict = true
exclude = [
".*/__pycache__/.*",
"docs/.*",
"build/.*",
"dist/.*",
]
## [tool.ruff]
## target-version = "py312"
## line-length = 120
## select = [
## "E", # Pycodestyle errors
## "F", # Pyflakes
## "W", # Pycodestyle warnings
## "UP", # Pyupgrade
## "I", # Isort
## "C4", # Comprehensions
## "ANN", # Annotations
## "DTZ", # Datetime zones
## ]
## ignore = [
## "ANN101", # Type annotation for self
## "ANN102", # Type annotation for cls
## ]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--verbose --cov-report term-missing:skip-covered"
python_files = "test_*.py"
python_classes = "Test*"
python_functions = "test_*"
[tool.coverage.paths]
my_project = ["src/my_project", "*/my-project/src/my_project"]
tests = ["tests", "*/my-project/tests"]
[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
[tool.coverage.run]
source = ["src"]
branch = true
parallel = true
omit = [
"src/my_project/__about__.py",
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment