[build-system] requires = ["setuptools>=68.0", "wheel", "setuptools-scm>=8.0"] build-backend = "setuptools.build_meta" [project] name = "appinfra" dynamic = ["version"] description = "Infrastructure framework for Python applications" readme = "README.md" authors = [ {name = "LLM Works LLC", email = "info@llm-works.ai"} ] requires-python = ">=3.11" classifiers = [ "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", ] dependencies = [ "PyYAML>=6.0,<7.0", "requests>=2.32.0,<3.0.0", "typing_extensions>=4.6.0", "urllib3>=2.6.0,<3.0.0", ] [project.urls] Homepage = "https://github.com/llm-works/appinfra" Repository = "https://github.com/llm-works/appinfra" Issues = "https://github.com/llm-works/appinfra/issues" [project.optional-dependencies] # The tools the Makefile framework's checks run; `make setup` installs them in every project check = [ "coverage>=7.4.0,<8.0.0", "ruff>=0.16.0,<1.0.0", # 0.16 is the first to format-check the Python blocks in .md files "mypy>=2.0.0,<3.0.0", "pytest>=8.3.0,<10.0.0", # 8.3 adds MarkMatcher.from_markers, which appinfra.pytest_suites uses "pytest-cov>=4.0.0,<8.0.0", "pytest-xdist>=3.2.0,<4.0.0", "interrogate>=1.5.0,<2.0.0", # deps_report.py (make deps): requirements, ranges and versions; 22 drops legacy versions "packaging>=22.0,<27.0", # 4.1 made duplicate-code fast on large trees. Capped at the tested minor: cq dup's plugin # patches astroid, whose version pylint pins. "pylint>=4.1.0,<4.2", ] dev = [ "appinfra[check]", "setuptools>=68.0", "types-PyYAML>=6.0.0,<7.0.0", "types-setuptools>=80.0.0,<85.0.0", "pytest-asyncio>=0.24.0,<2.0.0", # 0.24 adds asyncio_default_fixture_loop_scope "hypothesis>=6.0.0,<7.0.0", "pip-audit>=2.0.0,<3.0.0", # starlette.testclient takes httpx2 from Starlette 1.2 on and warns when it falls back to httpx "httpx2>=2.0.0,<3.0.0", "starlette>=1.2.0,<2.0.0", ] validation = [ "pydantic>=2.0.0,<3.0.0", ] docs = [ "mkdocs>=1.5.3,<2.0.0", "mkdocs-material>=9.5.0,<10.0.0", "mkdocstrings[python]>=1.0.0,<2.0.0", "mkdocs-autorefs>=1.4.0,<2.0.0", ] fastapi = [ # Both are 0.x and break APIs in minor releases: capped one minor past the newest # tested version, raised after testing a newer one "fastapi>=0.100.0,<0.163", "uvicorn[standard]>=0.23.0,<0.55", ] hotreload = [ "watchdog>=3.0.0,<5.0.0", ] ui = [ "rich>=13.0.0,<14.0.0", "questionary>=2.0.0,<3.0.0", "InquirerPy>=0.3.0,<1.0.0", ] sql = [ # 2.1 maps postgresql:// URLs to psycopg 3; 2.0 maps them to psycopg2 "sqlalchemy>=2.1.0,<3.0.0", # 0.43 no longer subclasses ScalarAttributeImpl, which SQLAlchemy 2.1 made private "sqlalchemy-utils>=0.43.0,<1.0.0", "psycopg[binary]>=3.2.0,<4.0.0", ] service = [ # No additional dependencies - service module uses stdlib only ] all = [ "appinfra[dev]", "appinfra[docs]", "appinfra[sql]", "appinfra[ui]", "appinfra[fastapi]", "appinfra[validation]", "appinfra[hotreload]", "appinfra[service]", ] [project.scripts] appinfra = "appinfra.cli.cli:main" [project.entry-points."setuptools.finalize_distribution_options"] appinfra_build_info = "appinfra.version.setuptools_hook:finalize_hook" [tool.ruff] line-length = 88 target-version = "py311" exclude = [".build", ".dist", ".cover", ".htmlcov", ".site"] [tool.ruff.lint] select = [ "E", # pycodestyle errors "W", # pycodestyle warnings "F", # pyflakes "I", # isort "N", # pep8-naming "UP", # pyupgrade "UP037", # Remove quotes from annotations (explicit for policy enforcement) "C90", # mccabe complexity "SIM", # flake8-simplify "RET", # flake8-return "PIE", # flake8-pie "PERF", # perflint "FURB", # refurb "C4", # flake8-comprehensions ] ignore = [ "E501", # line too long (handled by formatter) ] [tool.ruff.lint.mccabe] max-complexity = 10 [tool.ruff.lint.isort] known-first-party = ["appinfra"] [tool.ruff.lint.per-file-ignores] "appinfra/examples/**/*.py" = [ "E402", # Module import not at top (examples modify sys.path) "F841", # Unused variables (demonstration code) "F821", # Undefined names (examples may use forward references) "C90", "SIM", "RET", "PIE", "PERF", "FURB", "C4", # code-quality rules: core code only ] "tests/**/*.py" = [ "N806", # Variable name should be lowercase (Mock classes in tests) "N802", # Function name should be lowercase (HTTP methods like do_GET) "F841", # Local variable assigned but unused (test setup) "E731", # Lambda assignment (test helpers) "E402", # Module import not at top (tests modify sys.path) ] "appinfra/**/__init__.py" = [ "F401", # Imported but unused (re-exports) "F403", # Wildcard import (convenience imports) "F405", # May be undefined from star imports (re-exports) ] "appinfra/log/formatters.py" = ["N802"] # formatTime overrides logging.Formatter "appinfra/log/logger.py" = ["N802"] # _makeRecord, findCaller override logging.Logger "appinfra/log/__init__.py" = ["E402"] # ColorManager import after level definitions "appinfra/app/server/base.py" = ["N802"] # server_do_GET/POST/PUT/DELETE (HTTP methods) "appinfra/log/factory.py" = ["N805"] # Static method with non-self first param "appinfra/config/schemas.py" = ["N815"] # Pydantic fields match logging.handlers naming "appinfra/db/db.py" = ["N818"] # Exception naming convention (historical) "appinfra/cli/cli.py" = ["E402"] # sys.path modification before imports (script mode) "appinfra/examples/06_advanced/tcp_server.py" = ["N802"] # do_GET HTTP method [tool.ruff.format] quote-style = "double" indent-style = "space" line-ending = "auto" [tool.mypy] python_version = "3.11" strict = true # Calls into methods the library stubs leave unannotated: Loader inherits dispose, resolve and # add_multi_constructor from yaml.SafeLoader; sqlalchemy.dialects.postgresql.dialect (the # psycopg dialect) has an unannotated __init__. untyped_calls_exclude = ["appinfra.yaml.loader.Loader", "sqlalchemy.dialects.postgresql"] exclude = ["tests/", "scripts/", ".build/", ".dist/", ".cover/", ".htmlcov/", ".site/"] # No usable type information. sqlalchemy_utils has no py.typed, and its only stub package # (types-sqlalchemy-utils) is built on the SQLAlchemy 1.4 stubs, not SQLAlchemy 2.0's own types. # pgvector has no py.typed or stubs; it is in no extra (db/pg/vector.py imports it lazily). # astroid has no py.typed or stubs; cq's pylint plugin imports it. [[tool.mypy.overrides]] module = ["sqlalchemy_utils", "pgvector.*", "astroid.*"] ignore_missing_imports = true [tool.pytest.ini_options] testpaths = ["tests"] python_files = ["test_*.py", "*_test.py"] addopts = "-v --tb=short" pythonpath = ["."] # Set explicitly: unset, pytest-asyncio warns in every pytest process asyncio_default_fixture_loop_scope = "function" # Any warning fails the test that raises it. A known one is ignored per test, with the reason # beside the mark (tests/helpers/fork.py), never here for the whole suite. filterwarnings = ["error"] # The suite markers (unit, integration, e2e, security, performance) are registered by # appinfra.pytest_suites, loaded from tests/conftest.py. markers = [ "require_pg: Test requires a running PostgreSQL server (skipped with a single banner if unavailable)", ] [tool.coverage.run] source = ["appinfra"] # Pytest plugins are imported before coverage starts, so their module-level lines never count. omit = ["*/test/*", "*/tests/*", "*_test.py", "*/testing.py", "*/scripts/check_pytest/*"] [tool.coverage.report] precision = 2 exclude_lines = [ "pragma: no cover", "def __repr__", "raise AssertionError", "raise NotImplementedError", "if __name__ == .__main__.:", "if TYPE_CHECKING:", ] [tool.coverage.html] directory = ".htmlcov" [tool.coverage.json] output = ".coverage.json" [tool.coverage.annotate] directory = ".build/coverage-annotate" [tool.setuptools_scm] # Version derived from git tags (e.g., v0.1.0 -> 0.1.0) # Fallback for builds without git (e.g., Docker) fallback_version = "0.0.0.dev0" [tool.setuptools.packages.find] where = ["."] include = ["appinfra*"] exclude = ["tests*", "scripts*", "etc*"] [tool.setuptools.package-data] appinfra = [ "py.typed", "docs/**/*.md", "docs/LICENSE", "examples/**/*.py", "examples/**/*.md", "examples/**/*.yaml", "cli/tools/scaffold/*.in", "scripts/make/*", "scripts/*.sh", "scripts/*.py", "scripts/check_pytest/*.py", "scripts/docker/**/*", "etc/*.yaml", "etc/README.md", ]