Files
python-sdk/pyproject.toml
T
zeekay ac312e12da fix: Convert test functions to proper pytest format
- Refactor tests in test_workflow.py, test_memory.py, and test_signal_handling.py
  to use assertions instead of returning booleans (pytest strict mode requires None)
- Fix test_batch_orchestrator.py to mock file finding to avoid filesystem scans
- Add 'integration' pytest marker to both root pyproject.toml and pkg/hanzo/pytest.ini
- Account for system memories in memory manager tests
2025-12-09 14:52:53 -08:00

390 lines
8.7 KiB
TOML

[project]
name = "hanzoai"
version = "2.1.2"
description = "The official Python library for the Hanzo API"
dynamic = ["readme"]
license = "BSD-3-Clause"
authors = [
{ name = "Hanzo", email = "[email protected]" },
]
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
# Security: pin minimum versions to address vulnerabilities
"h11>=0.16.0",
"urllib3>=2.6.0",
]
requires-python = ">= 3.9"
classifiers = [
"Typing :: Typed",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: BSD License"
]
[project.optional-dependencies]
litellm = ["litellm>=1.0.0"]
[project.urls]
Homepage = "https://github.com/hanzoai/python-sdk"
Repository = "https://github.com/hanzoai/python-sdk"
[tool.rye]
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
"pyright>=1.1.359",
"mypy",
"respx",
"pytest",
"pytest-asyncio",
"ruff",
"time-machine",
"nox",
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0",
]
[tool.rye.workspace]
members = [
"pkg/hanzo",
"pkg/hanzo-aci",
"pkg/hanzo-agents",
"pkg/hanzo-mcp",
"pkg/hanzo-memory",
"pkg/hanzo-network",
"pkg/hanzo-repl",
"pkg/hanzoai",
]
[tool.rye.scripts]
format = { chain = [
"format:ruff",
"format:docs",
"fix:ruff",
# run formatting again to fix any inconsistencies when imports are stripped
"format:ruff",
]}
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
"format:ruff" = "ruff format"
"lint" = { chain = [
"check:ruff",
"typecheck",
"check:importable",
]}
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."
"check:importable" = "python -c 'import hanzoai'"
typecheck = { chain = [
"typecheck:pyright",
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes hanzoai --ignoreexternal"
"typecheck:mypy" = "mypy ."
[build-system]
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"
[dependency-groups]
dev = [
"build>=1.2.2.post1",
]
[tool.hatch.build]
include = [
"pkg/hanzoai"
]
[tool.hatch.build.targets.wheel]
packages = ["pkg/hanzoai"]
[tool.hatch.build.targets.sdist]
# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc)
include = [
"/*.toml",
"/*.json",
"/*.lock",
"/*.md",
"/mypy.ini",
"/noxfile.py",
"bin/*",
"examples/*",
"pkg/hanzoai/*",
"tests/*",
]
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.md"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# replace relative links with absolute links
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
replacement = '[\1](https://github.com/hanzoai/python-sdk/tree/main/\g<2>)'
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--tb=short"
xfail_strict = true
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
markers = [
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')"
]
filterwarnings = [
"error",
"ignore:OpenTelemetry configuration.*is not supported by Datadog:UserWarning",
"ignore::DeprecationWarning:ddtrace.*",
"ignore:Support for class-based `config` is deprecated:pydantic.warnings.PydanticDeprecatedSince20"
]
[tool.pyright]
# this enables practically every flag given by pyright.
# there are a couple of flags that are still disabled by
# default in strict mode as they are experimental and niche.
typeCheckingMode = "strict"
pythonVersion = "3.8"
exclude = [
"_dev",
".venv",
".nox",
]
reportImplicitOverride = true
reportImportCycles = false
reportPrivateUsage = false
[tool.ruff]
line-length = 120
output-format = "grouped"
target-version = "py38"
exclude = [
"pkg/hanzo-agent", # submodule - linted separately
"pkg/hanzo-memory", # needs careful review - has complex redefinitions
]
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint]
select = [
# isort
"I",
# bugbear rules
"B",
# remove unused imports
"F401",
# bare except statements
"E722",
# unused arguments
"ARG",
# misuse of typing.TYPE_CHECKING
# import rules
"TID251",
# docstring issues
"D",
# logging format
"G",
# security
"S",
# module imports
"E402",
# star imports
"F403",
# undefined names
"F821",
]
ignore = [
# mutable defaults
"B006",
# Unused function/method arguments - OK for protocol methods
"ARG001",
"ARG002",
"ARG003",
"ARG004",
"ARG005",
# Docstring formatting
"D205",
"D415",
# Line too long - handled by formatter
"E501",
# Ambiguous variable name
"E741",
# subprocess call - OK for CLI tools
"S603",
# Empty method in abstract base class
"B027",
# print statements - OK in examples and CLI tools
"T201",
"T203",
# Unused imports - we'll fix these manually
"F401",
# Undefined name - we'll fix these manually
"F821",
# raise without from inside except
"B904",
# logging format issues - OK for now
"G001",
"G002",
"G003",
# Unused loop control variable
"B007",
# subprocess without shell validation - OK for our use
"S605",
# try-except-pass - OK for optional imports
"S110",
# Missing docstrings - too many to fix now
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
# Other docstring issues
"D200",
"D201",
"D202",
"D203",
"D204",
"D206",
"D207",
"D208",
"D209",
"D210",
"D211",
"D212",
"D213",
"D214",
"D215",
"D300",
"D301",
"D400",
"D401",
"D402",
"D403",
"D404",
"D405",
"D406",
"D407",
"D408",
"D409",
"D410",
"D411",
"D412",
"D413",
"D414",
"D416",
"D417",
# Module level import not at top
"E402",
# Star imports
"F403",
# Loop variable binding
"B023",
# Use single if instead of nested - sometimes nested is clearer
"SIM102",
# Use of assert - OK in tests
"S101",
# Logging with f-string - performance is not critical
"G004",
# Starting process with partial path - OK for our use
"S607",
# Hardcoded temp directory - OK for tests
"S108",
# Popen without shell - OK
"S602",
# Starting process with shell - already handled
"S608",
# Use of random - OK for non-crypto use
"S311",
# Try-except-continue - OK
"S112",
# Insecure hash function - OK for non-crypto use
"S324",
# Request without timeout - OK for some cases
"S113",
# Hardcoded password - only in tests
"S106",
# os.system - OK for some CLI tools
"S606",
# eval - used safely in specific contexts
"S307",
# Hardcoded bind address - OK for examples
"S105",
# Use of exec - OK for specific use cases
"S102",
# Exception info in logging - OK
"G201",
]
unfixable = [
# disable auto fix for print statements
"T201",
"T203",
]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"
[tool.ruff.lint.isort]
length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["hanzoai", "tests"]
[tool.mypy]
python_version = "3.8"
ignore_missing_imports = true
exclude = [
"pkg/hanzo-mcp/tests/__init__.py",
]
[tool.ruff.lint.extend-per-file-ignores]
# Allow print statements in scripts and examples
"bin/**.py" = ["T201", "T203"]
"scripts/**.py" = ["T201", "T203", "E722"]
"tests/**.py" = ["T201", "T203", "F401", "F841"]
"examples/**.py" = ["T201", "T203", "F841"]
"**/examples/**.py" = ["T201", "T203", "F841"]
"pkg/**/examples/**.py" = ["T201", "T203", "F841"]
# CLI tools can use print
"**/cli*.py" = ["T201", "T203"]
"**/__main__.py" = ["T201", "T203"]
# Specific file ignores
"pkg/hanzo-memory/src/hanzo_memory/db/base.py" = ["B027"]
"pkg/hanzo-repl/src/hanzo_repl/backends.py" = ["S603"]
"pkg/hanzo-repl/src/hanzo_repl/repl.py" = ["S605"]
"pkg/hanzo-repl/src/hanzo_repl/tests.py" = ["ARG001"]
"pkg/hanzo-repl/src/hanzo_repl/ipython_repl.py" = ["ARG002"]
"**/cli.py" = ["T201", "T203"]
# Test files
"**/test_*.py" = ["F401", "F841"]
"**/tests/**.py" = ["F401", "F841"]