Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

14.9 KB
Raw Blame
[project]
name = "pipelex-api"
# The server is released with the library under one version number, read from the root `pyproject.toml`
# (`[tool.hatch.version]` below), so a release bumps one file. The dependencies are dynamic too: they are
# written in `[tool.hatch.metadata.hooks.custom]` below, whose hook pins pipelex to that version.
dynamic = ["version", "dependencies"]
description = "Pipelex API"
authors = [{ name = "Evotis S.A.S.", email = "[email protected]" }]
maintainers = [{ name = "Pipelex staff", email = "[email protected]" }]
license = "Elastic-2.0"
# A copy of the repository's `LICENSE`: a distribution can only carry license files from inside its own
# directory, and a symlink would dangle in the sdist. `tests/unit/test_license_copy.py` keeps the two equal.
license-files = ["LICENSE"]
readme = "README.md"
requires-python = ">=3.11,<3.15"
classifiers = [
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Programming Language :: Python :: 3.13",
  "Programming Language :: Python :: 3.14",
]

[build-system]
requires = ["hatchling>=1.27"]
build-backend = "hatchling.build"

[project.urls]
Homepage = "https://pipelex.com"
Repository = "https://github.com/Pipelex/pipelex"
Documentation = "https://docs.pipelex.com/latest/api-server/"
Changelog = "https://docs.pipelex.com/latest/changelog/"

[project.optional-dependencies]
dev = [
  "boto3-stubs>=1.35.24",
  # starlette>=1.3 's TestClient imports `httpx2 as httpx` under TYPE_CHECKING and at
  # runtime, falling back to httpx only with a deprecation warning. Installing httpx2
  # lets pyright resolve the TestClient signatures (otherwise every `client.post(...)`
  # is Unknown) and silences the runtime warning.
  "httpx2>=2.4.0",
  "mypy>=1.11.2",
  "pyright>=1.1.405",
  "pandas-stubs>=2.2.3.241126",
  "pylint>=3.3.8",
  "pytest>=8.3.3",
  "pytest-asyncio>=0.24.0",
  "pytest-cov>=6.1.1",
  "pytest-mock>=3.14.0",
  "pytest-sugar>=1.0.0",
  "pytest-xdist>= 3.6.1",
  "ruff>=0.6.8",
  "types-aiobotocore[bedrock,bedrock-runtime]>=3.0.0",
  "types-aiofiles>=24.1.0.20240626",
  "types-beautifulsoup4>=4.12.0.20240907",
  "types-markdown>=3.6.0.20240316",
  "types-networkx>=3.3.0.20241020",
  "types-openpyxl>=3.1.5.20250306",
  "types-requests>=2.32.0.2024091",
  "types-PyYAML>=6.0.12.20250326",
  "types-toml>=0.10.8.20240310",
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["pipelex_api"]

[tool.hatch.build.targets.sdist]
packages = ["pipelex_api"]

[tool.hatch.version]
path = "../pyproject.toml"
pattern = '(?m)^version = "(?P<version>[^"]+)"'

# The server's dependencies, which `hatch_build.py` writes into the distribution's metadata. Each requirement
# of `lockstep-dependencies` is pinned to `==` the release's own version, so a published `pipelex-api` installs
# exactly the pipelex it was released with; `dependencies` is copied as written. In the workspace, pipelex
# resolves from the same commit (`[tool.uv.sources]` below) and uv ignores the pin, so nothing here goes stale
# between releases. The release workflow checks the pin in the built wheel before it uploads it.
[tool.hatch.metadata.hooks.custom]
path = "hatch_build.py"
# The extras deliberately leave out `cli`: the runner selects the `json` log sink and a Rich-free pretty-print
# mode, so nothing it does on a request renders a terminal.
lockstep-dependencies = [
  "pipelex[mistralai,anthropic,google,google-genai,bedrock,fal]",
]
dependencies = [
  # FastAPI 0.142 changed how included routers are mounted, and the server's router assembly
  # (`pipelex_api/main.py`) loses every `/v1` route under it. The ceiling stays until that assembly is
  # adapted: the lock alone cannot hold it, since a published wheel installs whatever its metadata allows.
  "fastapi>=0.118.0,<0.142",
  "pyjwt>=2.10.1",
  "uvicorn>=0.37.0",
]

[tool.uv]
# The version comes from the root `pyproject.toml` and the dependencies from `hatch_build.py`, so uv has to
# rebuild this member's metadata when either changes, not only when this file does.
cache-keys = [
  { file = "pyproject.toml" },
  { file = "../pyproject.toml" },
  { file = "hatch_build.py" },
]

[tool.uv.sources]
pipelex = { workspace = true }

[tool.mypy]
check_untyped_defs = true
exclude = "^.*\\.venv/.*$"
mypy_path = "."
packages = ["pipelex_api", "tests"]
plugins = ["pydantic.mypy"]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = ["pipelex_api", "tests"]

[tool.pyright]
venvPath = "."
venv = ".venv"
pythonVersion = "3.11"
include = ["pipelex_api", "tests"]
exclude = [
  "**/__pycache__",
  ".venv",
  ".git",
  "build",
  "dist",
  "**/node_modules",
  "**/.*",
]
analyzeUnannotatedFunctions = true
deprecateTypingAliases = false
disableBytesTypePromotions = true
enableExperimentalFeatures = false
enableTypeIgnoreComments = true
extraPaths = ["./tests"]
reportAbstractUsage = "error"
reportArgumentType = "error"
reportAssertAlwaysTrue = "error"
reportAssertTypeFailure = "error"
reportAssignmentType = "error"
reportAttributeAccessIssue = "error"
reportCallInDefaultInitializer = true
reportCallIssue = "error"
reportConstantRedefinition = "error"
reportDeprecated = "error"
reportDuplicateImport = "error"
reportFunctionMemberAccess = "error"
reportGeneralTypeIssues = "error"
reportImplicitOverride = true
reportImplicitStringConcatenation = false
reportImportCycles = true
reportIncompatibleMethodOverride = "error"
reportIncompatibleVariableOverride = "error"
reportIncompleteStub = "error"
reportInconsistentConstructor = "error"
reportInconsistentOverload = "error"
reportIndexIssue = "error"
reportInvalidStringEscapeSequence = "error"
reportInvalidStubStatement = "error"
reportInvalidTypeArguments = "error"
reportInvalidTypeForm = "error"
reportInvalidTypeVarUse = "error"
reportMatchNotExhaustive = "error"
reportMissingImports = "error"
reportMissingModuleSource = "warning"
reportMissingParameterType = "error"
reportMissingSuperCall = "none"
reportMissingTypeArgument = "error"
reportMissingTypeStubs = false
reportNoOverloadImplementation = "error"
reportOperatorIssue = "error"
reportOptionalCall = "error"
reportOptionalContextManager = "error"
reportOptionalIterable = "error"
reportOptionalMemberAccess = "error"
reportOptionalOperand = "error"
reportOptionalSubscript = "error"
reportOverlappingOverload = "error"
reportPossiblyUnboundVariable = "error"
reportPrivateImportUsage = "error"
reportPrivateUsage = "error"
reportPropertyTypeMismatch = true
reportRedeclaration = "error"
reportReturnType = "error"
reportSelfClsParameterName = "error"
reportTypeCommentUsage = "error"
reportTypedDictNotRequiredAccess = "error"
reportUnboundVariable = "error"
reportUndefinedVariable = "error"
reportUninitializedInstanceVariable = "none"
reportUnknownArgumentType = "error"
reportUnknownLambdaType = "error"
reportUnknownMemberType = "error"
reportUnknownParameterType = "error"
reportUnknownVariableType = "error"
reportUnnecessaryCast = "error"
reportUnnecessaryComparison = "error"
reportUnnecessaryContains = "error"
reportUnnecessaryIsInstance = "error"
reportUnnecessaryTypeIgnoreComment = "none"
reportUnsupportedDunderAll = "error"
reportUntypedBaseClass = "error"
reportUntypedClassDecorator = "error"
reportUntypedFunctionDecorator = "error"
reportUntypedNamedTuple = "error"
reportUnusedCallResult = "none"
reportUnusedClass = "error"
reportUnusedCoroutine = "error"
reportUnusedExcept = "error"
reportUnusedExpression = "error"
reportUnusedFunction = "error"
reportUnusedImport = "none"
reportUnusedVariable = "error"
reportWildcardImportFromLibrary = "error"
strictDictionaryInference = true
strictListInference = true
strictParameterNoneValue = true
strictSetInference = true
typeCheckingMode = "strict"

[tool.pytest.ini_options]
addopts = "--import-mode=importlib -ra -m 'not gha_disabled'"
asyncio_default_fixture_loop_scope = "session"
markers = [
  "gha_disabled: tests that should not run in GitHub Actions",
  "builds_problems_without_required_params(reason): the test builds a problem lacking a parameter its code requires on purpose, which the sweep of tests/unit/conftest.py otherwise fails",
]
minversion = "8.0"
xfail_strict = true

[tool.coverage.run]
source = ["pipelex_api"]
omit = ["tests/*", "**/__init__.py"]

[tool.coverage.report]
exclude_lines = [
  "pragma: no cover",
  "def __repr__",
  "raise NotImplementedError",
  "if __name__ == .__main__.:",
  "pass",
  "raise ImportError",
]

[tool.ruff]
exclude = [
  ".claude",
  ".cursor",
  ".git",
  ".github",
  ".mypy_cache",
  ".ruff_cache",
  ".venv",
  ".vscode",
  "trigger_pipeline",
]
line-length = 150
target-version = "py311"

[tool.ruff.format]

[tool.ruff.lint]
select = ["ALL"]
ignore = [
  "ANN201",   # Missing return type annotation for public function `my_func`
  "ANN202",   # Missing return type annotation for private function `my_func`
  "ANN204",   # Missing return type annotation for special method `my_func`
  "ANN206",   #  Missing return type annotation for classmethod `my_func`
  "ANN401",   # Dynamically typed expressions (typing.Any) are disallowed in `...`
  "ASYNC230", # Async functions should not open files with blocking methods like `open`

  "C901", # Is to complex

  "CPY001", # Missing copyright notice at top of file: the repository's LICENSE covers every file, as in pipelex
  "COM812", # Checks for the absence of trailing commas.

  "D100", # Missing docstring in public module
  "D101", # Missing docstring in public class
  "D102", # Missing docstring in public method
  "D103", # Missing docstring in public function
  "D104", # Missing docstring in public package
  "D105", # Missing docstring in magic method
  "D107", # Missing docstring in __init__
  "D205", # 1 blank line required between summary line and description
  "D400", # First line should end with a period
  "D401", # First line of docstring should be in imperative mood: "My docstring...."
  "D404", # First word of the docstring should not be "This"
  "D415", # First line should end with a period, question mark, or exclamation point

  "DTZ001", # `datetime.datetime()` called without a `tzinfo` argument
  "DTZ005", # `datetime.datetime.now()` called without a `tz` argument

  "ERA001", # Found commented-out code

  "FBT001", # Boolean-typed positional argument in function definition
  "FBT002", # Boolean default positional argument in function definition
  "FBT003", #Boolean positional value in function call

  "FIX002", # Line contains TODO, consider resolving the issue

  "PLC0105", # `TypeVar` name "SomethingType" does not reflect its covariance; consider renaming it to "SomethingType_co"

  "PLR0911", # Too many return statements (/6)
  "PLR0912", # Too many branches (/12)
  "PLR0913", # Too many arguments in function definition (/5)
  "PLR0915", # Too many statements (/50)
  "PLR2004", # Magic value used in comparison, consider replacing `2` with a constant variable

  "PT013", # Incorrect import of `pytest`; use `import pytest` instead

  "PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
  "PTH103", # `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
  "PTH107", # `os.remove()` should be replaced by `Path.unlink()`
  "PTH109", # `os.getcwd()` should be replaced by `Path.cwd()`
  "PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator
  "PTH120", # `os.path.dirname()` should be replaced by `Path.parent`
  "PTH110", # `os.path.exists()` should be replaced by `Path.exists()`
  "PTH112", # `os.path.isdir()` should be replaced by `Path.is_dir()`
  "PTH119", # `os.path.basename()` should be replaced by `Path.name`
  "PTH123", # `open()` should be replaced by `Path.open()`
  "PTH208", # Use `pathlib.Path.iterdir()` instead.

  "PYI051", # `Literal["auto"]` is redundant in a union with `str`

  "RET505", # superfluous-else-return

  "RUF001", # String contains ambiguous `′` (PRIME). Did you mean ``` (GRAVE ACCENT)?
  "RUF003", # Comment contains ambiguous `’` (RIGHT SINGLE QUOTATION MARK). Did you mean ``` (GRAVE ACCENT)?

  "SIM105", # Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass`
  "SIM108", # Use ternary operator `description = func.__doc__.strip().split("\n")[0] if func.__doc__ else func.__name__` instead of `if`-`else`-block

  "S101", # Use of `assert` detected
  "S102", # Use of `exec` detected
  "S106", # Possible hardcoded password assigned to argument: "secret"
  "S105", # Possible hardcoded password assigned to: "child_secret"

  "TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
  "TD003", # Missing issue link for this TODO

  "T201", # `print` found

  # TODO: stop ignoring these rules
  "B027",    # Checks for empty methods in abstract base classes without an abstract decorator.
  "UP007",   # Use `X | Y` for type annotations
  "UP036",   # Version block is outdated for minimum Python version
  "SIM102",  # Use a single `if` statement instead of nested `if` statements
  "S701",    # Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
  "N818",    # Exception name `RootException` should be named with an Error suffix
  "TRY301",  # Abstract `raise` to an inner function
  "PERF401", # Use a list comprehension to create a transformed list
  "PLW2901", # `for` loop variable `line` overwritten by assignment target
  "TRY300",  # Consider moving this statement to an `else` block
  "UP035",   # `typing.List` is deprecated, use `list` instead
  "RET503",  # Missing explicit `return` at the end of function able to return non-`None` value
]

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

[tool.ruff.lint.flake8-type-checking]
# Pydantic resolves field annotations at runtime (model build / validation), so
# imports used only in annotations on a BaseModel subclass must stay at module
# scope — TC001/TC002/TC003 would otherwise push them into a TYPE_CHECKING block
# and break model construction.
# The pipelex bases below are themselves BaseModel subclasses, but ruff resolves this
# list by name and cannot see through the inheritance — so a model that documents the
# wire shape by subclassing one of them needs its base listed here explicitly too.
runtime-evaluated-base-classes = [
  "pydantic.BaseModel",
  "pipelex.core.pipes.pipe_output.PipeOutput",
  "pipelex.pipeline.pipeline_response.PipelexRunResultExecute",
  "pipelex.pipeline.pipeline_response.PipelexRunResultStart",
]

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = [
  "T201",   # Allow print statements in test files
  "INP001", # Allow test files to not have __init__.py in their directories (avoids namespace collisions)
  "S311",   # Seeded pseudo-random test data is not cryptography
]
"scripts/**/*.py" = [
  "INP001", # scripts/ is a directory of standalone entry points, not a package
]

[tool.pylint.main]
py-version = "3.11"
reports = false

[tool.pylint.messages_control]
disable = ["all"]
enable = [
  "W0101", # Unreachable code: Used when there is some code behind a "return" or "raise" statement, which will never be accessed.
]
ignore = [".venv", "__pycache__", "build", "dist", ".git"]