velofy/pyproject.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

676 lines
18 KiB
TOML
Raw Normal View History

[build-system]
build-backend = "uv_build"
requires = ["uv_build (>=0.13.10,<0.14.0)"] # Same range as in "[tool.uv]" below
[project]
name = "velofy"
version = "0.5.0.dev0"
authors = [{ name = "Alexander Hess", email = "alexander@webartifex.de" }]
description = "Optimizing an urban meal delivery platform"
keywords = [
"data-science",
"meal-delivery",
"vehicle-routing-problem",
]
license = "MIT"
readme = "README.md"
classifiers = [
# All `SUPPORTED_PYTHONS` listed here are automatically
# loaded by `nox`, our task runner, and made available
# for testing in isolated environments
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.13,<4.0"
# Package => Code developed in *.py files and packaged under src/velofy
dependencies = [
"Shapely (>=2.2.0,<3.0.0)",
"alembic (>=1.20.1,<2.0.0)",
"click (>=8.5.1,<9.0.0)",
"folium (>=1.0.0,<2.0.0)",
"geopy (>=2.5.0,<3.0.0)",
"googlemaps (>=4.10.0,<5.0.0)",
"matplotlib (>=3.11.2,<4.0.0)",
"ordered-set (>=4.1.0,<5.0.0)",
"pandas (>=3.1.1,<4.0.0)",
"psycopg[binary] (>=3.3.9,<4.0.0)", # Adapter for PostgreSQL
"rpy2 (>=3.6.9,<4.0.0)",
"sqlalchemy (>=2.1.9,<3.0.0)",
"statsmodels (>=0.15.0,<0.16.0)",
"utm (>=0.9.0,<0.10.0)",
]
[project.optional-dependencies]
# `jupyter lab` => Notebooks with analyses using the developed package
research = [
"jupyterlab (>=4.6.6,<5.0.0)",
"numpy (>=2.5.5,<3.0.0)",
"pytz (>=2026.6)",
]
[project.scripts]
manage = "velofy.console:cli"
[project.urls]
homepage = "https://code.webartifex.de/alexander/velofy"
repository = "https://code.webartifex.de/alexander/velofy"
[dependency-groups]
dev = [
# Task Runners
"nox (>=2026.10.20)",
"pre-commit (>=4.7.0,<5.0.0)",
# Code Formatters
"autoflake (>=2.4.0,<3.0.0)",
"black (>=25.12.0,<26.0.0)",
"flynt (>=1.0.6,<2.0.0)",
"isort (>=9.0.2,<10.0.0)",
# Code Analyzers
"flake8 (>=7.5.0,<8.0.0)",
"flake8-annotations (>=3.3.1,<4.0.0)",
2026-11-28 02:17:51 +01:00
"flake8-bandit (>=4.1.1,<5.0.0)",
"flake8-black (>=0.5.0,<0.6.0)",
2026-11-30 22:43:35 +01:00
"flake8-boolean-trap (>=1.0.1,<2.0.0)",
2026-11-28 02:28:27 +01:00
"flake8-broken-line (>=1.0.0,<2.0.0)",
2026-11-28 02:39:58 +01:00
"flake8-bugbear (>=26.11.22,<27.0.0)",
2026-11-30 21:40:43 +01:00
"flake8-builtins (>=3.2.0,<4.0.0)",
2026-11-28 02:44:35 +01:00
"flake8-commas (>=4.0.0,<5.0.0)",
2026-11-28 02:49:56 +01:00
"flake8-comprehensions (>=3.17.0,<4.0.0)",
2026-11-28 02:51:04 +01:00
"flake8-debugger (>=4.1.2,<5.0.0)",
2026-11-28 03:04:38 +01:00
"flake8-docstrings (>=1.7.0,<2.0.0)",
2026-11-30 21:09:05 +01:00
"flake8-implicit-str-concat (>=0.7.0,<0.8.0)",
"flake8-pyproject (>=1.2.4,<2.0.0)",
"flake8-pytest-style (>=2.2.0,<3.0.0)",
2026-11-28 03:21:46 +01:00
"flake8-quotes (>=3.4.0,<4.0.0)",
2026-11-30 21:03:23 +01:00
"flake8-return (>=1.2.0,<2.0.0)",
2026-11-28 03:34:40 +01:00
"flake8-sfs (>=1.0.1,<2.0.0)",
2026-11-30 20:57:31 +01:00
"flake8-simplify (>=0.31.1,<0.32.0)",
2026-11-28 03:37:25 +01:00
"flake8-todos (>=0.3.1,<0.4.0)",
"flake8-unused-arguments (>=0.0.14,<0.1.0)",
"mypy (>=2.4.1,<3.0.0)",
2026-11-30 22:11:10 +01:00
"pandas-vet (>=2023.8.2)",
2026-11-28 03:54:17 +01:00
"pep8-naming (>=0.15.1,<0.16.0)",
2026-11-28 04:06:53 +01:00
"pydoclint[flake8] (>=0.12.0,<0.13.0)",
"ruff (>=0.17.6,<0.18.0)",
]
test = [
"factory-boy (>=3.3.3,<4.0.0)",
"Faker (>=40.63.0,<41.0.0)",
"packaging (>=26.4)", # Used to test the packaged version
"pytest-cov (>=7.1.0,<8.0.0)",
"pytest-env (>=1.8.8,<2.0.0)",
"pytest-mock (>=3.17.0,<4.0.0)",
"pytest (>=9.2.0,<10.0.0)",
"xdoctest[colors] (>=1.3.2,<2.0.0)",
]
docs = [
"sphinx (>=9.2.0,<10.0.0)",
"sphinx-autodoc-typehints (>=3.17.7,<4.0.0)",
]
2026-11-25 16:03:14 +01:00
[tool.autoflake]
# Source: https://github.com/PyCQA/autoflake#configuration
in-place = true
recursive = true
expand-star-imports = true
remove-all-unused-imports = true
ignore-init-module-imports = true # modifies "remove-all-unused-imports"
remove-duplicate-keys = true
remove-unused-variables = true
[tool.black]
target-version = ["py313"]
line-length = 88
2026-11-25 14:38:14 +01:00
[tool.coverage]
# Source: https://coverage.readthedocs.io/en/latest/config.html
[tool.coverage.paths]
source = [
"src/",
"*/site-packages/",
]
[tool.coverage.report]
show_missing = true
skip_covered = true
skip_empty = true
[tool.coverage.run]
branch = true
data_file = ".cache/coverage/data"
source = ["velofy"]
[tool.flake8]
# Source: https://flake8.pycqa.org/en/latest/user/configuration.html
# Include error classes only explicitly
# to avoid forward compatibility issues.
select = [
# =============
# flake8's base
# =============
# mccabe => cyclomatic complexity
"C901",
# pycodestyle => PEP8 compliance
"E", "W",
# pyflakes => basic errors
"F4", "F5", "F6", "F7", "F8", "F9",
2026-11-28 04:08:39 +01:00
# =======
# plugins
# =======
# flake8-annotations => enforce type checking for functions
"ANN0", "ANN2", "ANN3",
# flake8-bandit => common security issues
"S1", "S2", "S3", "S4", "S5", "S6", "S7",
2026-11-28 04:08:39 +01:00
# flake8-black => complain if black would make changes
"BLK1", "BLK9",
2026-11-30 22:43:35 +01:00
# flake8-boolean-trap => Keyword-only flags
"FBT",
# flake8-broken-line => no \ to end a line
"N400",
# flake8-bugbear => opinionated bugs and design flaws
"B0", "B3", "B9",
2026-11-30 21:40:43 +01:00
# flake8-builtins => No shadowing of builtins
"A0",
# flake8-commas => better comma placements
"C8",
# flake8-comprehensions => better comprehensions
"C4",
# flake8-debugger => no debugger usage
"T100",
# flake8-docstrings => PEP257 compliance
"D1", "D2", "D3", "D4",
2026-11-30 21:09:05 +01:00
# flake8-implicit-str-concat => Unified string concatenation
"ISC",
# flake8-pytest-style => enforce a consistent style with pytest
"PT0",
2026-11-28 04:08:39 +01:00
# flake8-quotes => use double quotes everywhere (complying with black)
"Q0",
2026-11-30 21:03:23 +01:00
# flake8-return => Consistent return statements
"R5",
2026-11-28 03:34:40 +01:00
# flake8-sfs => use f-strings as the only type of string formatting
"SFS",
2026-11-30 20:57:31 +01:00
# flake8-simplify => Simpler code
"SIM",
2026-11-28 03:37:25 +01:00
# flake8-todos => unify TODOs
"T00",
# flake8-unused-arguments => declared function arguments must be used
"U100",
2026-11-30 22:11:10 +01:00
# pandas-vet => Idiomatic `pandas`
"PD0",
2026-11-28 04:08:39 +01:00
# pep8-naming => PEP8 naming conventions
"N8",
# pydoclint => docstring matches implementation
"DOC",
2026-11-30 20:52:01 +01:00
# ========================================
# `ruff` only (no working `flake8` plugin)
# ========================================
2026-11-30 21:33:43 +01:00
# refurb => Modern idioms
# "FURB",
2026-11-30 22:49:41 +01:00
# NumPy-specific rules => Modern `numpy` APIs
# "NPY",
2026-11-30 21:31:38 +01:00
# Perflint => No performance anti-patterns
# "PERF",
2026-11-30 22:28:12 +01:00
# Pylint => Fewer bugs and simpler code
# "PL",
2026-11-30 21:11:14 +01:00
# flake8-use-pathlib => `pathlib` instead of `os` functions
# "PTH",
2026-11-30 22:35:24 +01:00
# flake8-self => No access to private members from outside
# "SLF",
2026-11-30 20:52:01 +01:00
# pyupgrade => Modern syntax for the targeted Python version
# "UP",
]
# By default, flake8 ignores some errors.
# Instead, do not ignore anything.
ignore = []
# If --ignore is passed on the command
# line, still ignore the following:
extend-ignore = [
2026-11-30 21:40:43 +01:00
# `ruff`'s A003 does this better, as it only flags actual shadowing
"A003",
# Too long line => duplicate with E501.
"B950",
2026-11-28 04:06:53 +01:00
# PEP 257 documents the arguments of `__init__()` in its own docstring.
"DOC301",
# Comply with black's style.
# Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8
2026-11-28 02:01:12 +01:00
"E203", "W503",
2026-11-30 22:43:35 +01:00
# `ruff`'s FBT003 does this better, as it allows builtins like `setattr()`.
"FBT003",
2026-11-30 22:11:10 +01:00
# Every `.add()` looks like `pandas` to this rule (`ruff` omits it).
"PD005",
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
"PT023",
2026-11-30 21:03:23 +01:00
# `ruff`'s RET504 does this better, as it allows statements in between.
"R504",
# An `elif` after a `return` keeps a case distinction together.
"R505",
2026-11-28 03:34:40 +01:00
# Allow f-strings as the only type of string formatting.
"SFS301",
2026-11-30 20:57:31 +01:00
# `bool()` around a comparison can be deliberate (`ruff` omits this rule).
"SIM901",
2026-11-28 03:37:25 +01:00
# TODOs need neither an author nor an issue.
"T002", "T003",
]
per-file-ignores = [
# Top-levels of a sub-packages are intended to import a lot.
2026-11-28 02:01:12 +01:00
"**/__init__.py:F401",
# Type annotations are not strictly enforced.
"migrations/env.py:ANN0,ANN2",
# - ANN0, ANN2 => Type annotations are not strictly enforced.
# - S608 => Do not worry about SQL injection here.
2026-11-28 02:01:12 +01:00
"migrations/versions/*.py:ANN0,ANN2,S608",
# Type annotations are not strictly enforced.
"noxfile.py:ANN0,ANN2",
2026-11-28 04:06:53 +01:00
# - ANN0, ANN2, DOC106, DOC107 => Type annotations are not strictly enforced.
# - D106 => The `Meta` class inside the factory_boy models do not need a docstring.
# - S101 => `assert` statements are ok in the test suite.
# - S311 => The `random` module is not used for cryptography.
2026-11-28 04:06:53 +01:00
"tests/*.py:ANN0,ANN2,D106,DOC106,DOC107,S101,S311",
]
# Explicitly set mccabe's maximum complexity to 10 as recommended by
# Thomas McCabe, the inventor of the McCabe complexity, and the NIST.
# Source: https://en.wikipedia.org/wiki/Cyclomatic_complexity#Limiting_complexity_during_development
max-complexity = 10
# Comply with black's style.
# Source: https://github.com/psf/black/blob/master/docs/the_black_code_style.md#line-length
max-line-length = 88
# Preview the code lines that cause errors.
show-source = true
2026-11-28 04:06:53 +01:00
# pydoclint
style = "google"
arg-type-hints-in-docstring = false
check-return-types = false
check-yield-types = false
# flake8-docstrings
docstring-convention = "google"
2026-11-28 03:21:46 +01:00
# flake8-quotes
# Source: https://github.com/zheller/flake8-quotes#configuration
avoid-escape = true
docstring-quotes = "double"
inline-quotes = "double"
multiline-quotes = "double"
# flake8-unused-arguments
unused-arguments-ignore-abstract-functions = true
# ==============================
# flake8-pytest-style's settings
# ==============================
# Prefer @pytest.fixture over @pytest.fixture().
pytest-fixture-no-parentheses = true
# Prefer @pytest.mark.parametrize(['param1', 'param2'], [(1, 2), (3, 4)])
# over @pytest.mark.parametrize(('param1', 'param2'), ([1, 2], [3, 4]))
pytest-parametrize-names-type = "list"
pytest-parametrize-values-row-type = "tuple"
pytest-parametrize-values-type = "list"
2026-11-25 14:49:12 +01:00
[tool.isort]
# Source: https://pycqa.github.io/isort/docs/configuration/options.html
atomic = true
case_sensitive = false # Implied by "force_alphabetical_sort_within_sections"
2026-11-25 14:49:12 +01:00
combine_star = true
force_alphabetical_sort_within_sections = true
lines_after_imports = 2
remove_redundant_aliases = true
# Comply with black's style
# Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#isort
ensure_newline_before_comments = true
force_grid_wrap = 0
include_trailing_comma = true
line_length = 88
multi_line_output = 3
use_parentheses = true
# Comply with Google's Python Style Guide
# => All imports go on a single line
2026-11-25 14:49:12 +01:00
# Source: https://google.github.io/styleguide/pyguide.html#313-imports-formatting
force_single_line = true
2026-11-25 14:46:02 +01:00
[tool.mypy]
# Source: https://mypy.readthedocs.io/en/stable/config_file.html
cache_dir = ".cache/mypy"
# Check the interior of functions without type annotations
check_untyped_defs = true
# Disallow generic types without explicit type parameters
disallow_any_generics = true
# Disallow functions with incomplete type annotations
disallow_incomplete_defs = true
# Disallow calling functions without type annotations ...
2026-11-25 14:46:02 +01:00
disallow_untyped_calls = true
# ... except for libraries without type annotations
untyped_calls_exclude = [
"folium",
]
2026-11-25 14:46:02 +01:00
# Disallow functions without type annotations (or incomplete annotations)
disallow_untyped_defs = true
# Require an error code in all "# type: ignore" comments
enable_error_code = ["ignore-without-code"]
# Report "# type: ignore" comments that are not needed anymore
warn_unused_ignores = true
2026-11-25 14:46:02 +01:00
[[tool.mypy.overrides]]
module = [
"geopy.*",
"googlemaps.*",
"pandas",
"rpy2.*",
"statsmodels.*",
"utm.*",
]
ignore_missing_imports = true
2026-11-25 14:43:31 +01:00
[tool.pytest.ini_options]
# Source: https://docs.pytest.org/en/stable/reference/reference.html#ini-options-ref
cache_dir = ".cache/pytest"
testpaths = ["tests"]
# "-ra" => Summarize skipped and `xfailed tests at the end
addopts = "-ra --strict-config --strict-markers"
2026-11-25 14:43:31 +01:00
console_output_style = "count"
xfail_strict = true
required_plugins = [
"pytest-cov",
"pytest-env",
"pytest-mock",
]
2026-11-25 14:43:31 +01:00
env = [
"TESTING=true",
]
filterwarnings = [
"error", # Turn all warnings into errors
2026-11-25 14:43:31 +01:00
]
markers = [
"db: (integration) tests touching the database",
"e2e: non-db and non-r integration tests",
"r: (integration) tests using rpy2",
]
[tool.ruff]
# Source: https://docs.astral.sh/ruff/
cache-dir = ".cache/ruff"
src = ["src"]
target-version = "py313"
line-length = 88
[tool.ruff.format]
# Align with black
quote-style = "double"
skip-magic-trailing-comma = false
[tool.ruff.lint] # aligned with [tool.flake8] above
select = [
# ===================================
# Violations also covered by `flake8`
# ===================================
2026-11-30 21:40:43 +01:00
# flake8-builtins => No shadowing of builtins
"A",
# flake8-annotations => enforce type checking for functions
"ANN0", "ANN2",
# flake8-unused-arguments ("U100") => declared function arguments must be used
"ARG",
# flake8-bugbear => opinionated bugs and design flaws
"B",
# flake8-comprehensions => better comprehensions
"C4",
# mccabe => cyclomatic complexity
"C90",
# flake8-commas ("C8") => better comma placements
"COM",
# flake8-docstrings => PEP257 compliance
"D",
# pycodestyle => PEP8 compliance
"E", "W",
# pyflakes => basic errors
"F",
2026-11-30 22:43:35 +01:00
# flake8-boolean-trap => Keyword-only flags
"FBT",
2026-11-30 21:09:05 +01:00
# flake8-implicit-str-concat => Unified string concatenation
"ISC",
# pep8-naming => PEP8 naming conventions
"N",
2026-11-30 22:11:10 +01:00
# pandas-vet => Idiomatic `pandas`
"PD",
# flake8-pytest-style => enforce a consistent style with pytest
"PT",
# flake8-quotes => use double quotes everywhere
"Q",
2026-11-30 21:03:23 +01:00
# flake8-return ("R5") => Consistent return statements
"RET",
# flake8-bandit => common security issues
"S",
2026-11-30 20:57:31 +01:00
# flake8-simplify => Simpler code
"SIM",
# flake8-debugger => no debugger usage
"T10",
# flake8-todos => unify TODOs
"TD",
# =======================================
# Violations not covered by `flake8` above
# =======================================
# eradicate => no commented-out code
"ERA",
2026-11-30 21:33:43 +01:00
# refurb => Modern idioms
"FURB",
# isort => imports are sorted
"I",
# flake8-import-conventions => Unified import aliases
"ICN",
2026-11-30 22:49:41 +01:00
# NumPy-specific rules => Modern `numpy` APIs
"NPY",
2026-11-30 21:31:38 +01:00
# Perflint => No performance anti-patterns
"PERF",
2026-11-30 22:28:12 +01:00
# Pylint => Fewer bugs and simpler code
"PL",
2026-11-30 21:11:14 +01:00
# flake8-use-pathlib => `pathlib` instead of `os` functions
"PTH",
2026-11-30 22:35:24 +01:00
# flake8-self => No access to private members from outside
"SLF",
# flake8-print => no `print()`
"T20",
2026-11-30 20:52:01 +01:00
# pyupgrade => Modern syntax for the targeted Python version
"UP",
]
extend-ignore = [
# Let the formatter handle trailing commas.
"COM812",
2026-11-28 04:57:25 +01:00
# Thresholds like the ones in the maps read better as literals.
"PLR2004",
# Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`.
"PT023",
2026-11-30 21:03:23 +01:00
# An `elif` after a `return` keeps a case distinction together.
"RET505",
# TODOs need neither an author nor an issue.
"TD002", "TD003",
]
[tool.ruff.lint.per-file-ignores]
# Top-levels of a sub-packages are intended to import a lot.
"**/__init__.py" = ["F401"]
# Type annotations are not strictly enforced.
"migrations/env.py" = ["ANN0", "ANN2"]
# - ANN0, ANN2 => Type annotations are not strictly enforced.
# - S608 => Do not worry about SQL injection here.
"migrations/versions/*.py" = ["ANN0", "ANN2", "S608"]
# Type annotations are not strictly enforced.
"noxfile.py" = ["ANN0", "ANN2"]
# `print()` is ok in ad-hoc scripts
"scripts/**" = ["T20"]
# - ANN0, ANN2 => Type annotations are not strictly enforced.
# - D106 => The `Meta` class inside the factory_boy models do not need a docstring.
2026-11-28 04:57:25 +01:00
# - PLR0913, PLR0917 => `pytest` passes fixtures as arguments.
# - S101 => `assert` statements are ok in the test suite.
# - S311 => The `random` module is not used for cryptography.
2026-11-30 22:35:24 +01:00
# - SLF001 => Tests may set up and inspect private members.
"tests/**/*.py" = ["ANN0", "ANN2", "D106", "PLR0913", "PLR0917", "S101", "S311", "SLF001"]
[tool.ruff.lint.flake8-pytest-style] # aligned with [tool.flake8] above
fixture-parentheses = false
parametrize-names-type = "list"
parametrize-values-row-type = "tuple"
parametrize-values-type = "list"
[tool.ruff.lint.flake8-import-conventions]
# Import modules instead of objects from these modules
banned-from = [
"collections.abc",
"nox.sessions",
"typing",
]
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
"alembic.command" = "alembic_cmd"
"alembic.config" = "alembic_config"
"click.core" = "cli_core"
"click.testing" = "cli_testing"
"collections.abc" = "cabc"
"geopy.distance" = "geo_distance"
2026-11-25 14:46:02 +01:00
"googlemaps" = "gm"
"logging.config" = "log_config"
"packaging.version" = "pkg_version"
"rpy2.rinterface_lib.callbacks" = "r_callbacks"
"rpy2.robjects.packages" = "r_packages"
"sqlalchemy" = "sa"
"sqlalchemy.dialects.postgresql" = "psql"
"sqlalchemy.exc" = "sa_exc"
"sqlalchemy.ext.hybrid" = "sa_hybrid"
"sqlalchemy.orm.exc" = "orm_exc"
2026-11-25 14:46:02 +01:00
"statsmodels.tsa.api" = "tsa"
"tests.config" = "test_config"
"typing" = "t"
"velofy.config" = "pkg_config"
[tool.ruff.lint.isort] # aligned with [tool.isort] above
case-sensitive = false # Same as `isort`
force-single-line = true
lines-after-imports = 2
order-by-type = false
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.uv]
# Source: https://docs.astral.sh/uv/reference/settings/
required-version = ">=0.13.10,<0.14.0" # Same range as "uv_build" above
# `uv sync` installs all [dependency-groups] into the local develop environment
# whereas the `nox` sessions install only the groups they need
default-groups = "all"
# Rebuild the package when its source files change;
# by default, `uv` only watches the pyproject.toml file
cache-keys = [
{ file = "pyproject.toml" },
{ file = "src/**/*.py" },
]