diff --git a/pyproject.toml b/pyproject.toml index e48023ef2..8609a4f87 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,205 +1,208 @@ +[build-system] +requires = ["hatchling>=1.25.0", "hatch-vcs>=0.4.0"] +build-backend = "hatchling.build" + [project] name = "codegen" -dynamic = ["version", "urls"] -description = "Scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter" +dynamic = ["version"] +description = "Codegen CLI - Transform your code with AI." readme = "README.md" -# renovate: datasource=python-version depName=python requires-python = ">=3.12, <3.14" dependencies = [ "codegen-api-client", - "typer>=0.12.5", + "typer>=0.16.0", "rich>=13.7.1", "hatch-vcs>=0.4.0", "hatchling>=1.25.0", - # CLI and git functionality dependencies - "requests>=2.32.3", - "pydantic>=2.9.2", - "pydantic-settings>=2.0.0", - "PyGithub==2.6.1", - "GitPython==3.1.44", + "humanize>=4.10.0", "packaging>=24.2", - "python-dotenv>=1.0.1", - "giturlparse", - "codeowners>=0.6.0", - "unidiff>=0.7.5", - "datamodel-code-generator>=0.26.5", - "fastmcp>=2.9.0", - # Utility dependencies - "colorlog>=6.9.0", "psutil>=5.8.0", - "sentry-sdk==2.29.1", - "humanize>=4.10.0", + "pydantic>=2.9.2", + "python-dotenv>=1.0.1", + "requests>=2.31.0", + "typing-extensions>=4.12.2", + "urllib3>=2.2.2", +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.2.2", + "pytest-cov>=5.0.0", + "pytest-xdist>=3.6.1", + "pytest-sugar>=1.0.0", + "pytest-mock>=3.14.0", + "pytest-timeout>=2.3.1", + "pytest-rerunfailures>=14.0", + "pytest-randomly>=3.15.0", + "pytest-freezegun>=0.4.2", + "pytest-httpserver>=1.0.10", + "pytest-html>=4.1.1", + "pytest-metadata>=3.1.1", + "pytest-clarity>=1.0.1", + "pytest-benchmark>=4.0.0", + "pytest-profiling>=1.7.0", + "pytest-repeat>=0.9.3", + "pytest-ordering>=0.6", + "pytest-lazy-fixture>=0.6.3", + "pytest-cases>=3.8.1", + "pytest-check>=2.3.1", + "pytest-subtests>=0.11.0", + "pytest-testmon>=2.1.0", + "pytest-testinfra>=10.1.0", + "pytest-testinfra>=10.1.0", + "pytest-testinfra>=10.1.0", + "pytest-testinfra>=10.1.0", + "pytest-testinfra>=10.1.0", ] -# renovate: datasource=python-version depName=python -license = { text = "Apache-2.0" } classifiers = [ "Development Status :: 4 - Beta", - "Environment :: Console", - "Environment :: MacOS X", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", "License :: OSI Approved", "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", "Topic :: Software Development", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", ] -authors = [{ name = "Codegen Team", email = "team@codegen.sh" }] -keywords = [ - "codegen", - "codebase", - "codebase manipulation", - "codebase analysis", - "codebase transformation", - "refactoring", - "code generation", -] + +[project.urls] +Documentation = "https://docs.codegen.com" +Issues = "https://github.com/codegen-sh/codegen/issues" +Source = "https://github.com/codegen-sh/codegen" + [project.scripts] codegen = "codegen.cli.cli:main" -[project.optional-dependencies] -types = [] -[tool.uv] -cache-keys = [{ git = { commit = true, tags = true } }] +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.sdist] +exclude = [ + "/.github", + "/docs", + "/.gitignore", + "/.pre-commit-config.yaml", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/codegen"] + +[project.optional-dependencies.dev-dependencies] dev-dependencies = [ - "coverage<8.0.0,>=7.6.1", - "filelock<4.0.0,>=3.15.4", - "pytest>=8.3.3", - "pytest-cov>=6.1.0,<6.1.1", - "ruff>=0.6.8", - "ty>=0.0.1a10", - "pre-commit>=4.0.1", - "pytest-xdist>=3.6.1,<4.0.0", - "pytest-mock<4.0.0,>=3.14.0", + "pytest>=8.2.2", + "pytest-cov>=5.0.0", + "pytest-xdist>=3.6.1", + "pytest-sugar>=1.0.0", + "pytest-mock>=3.14.0", "pytest-timeout>=2.3.1", + "pytest-rerunfailures>=14.0", + "pytest-randomly>=3.15.0", + "pytest-freezegun>=0.4.2", + "pytest-httpserver>=1.0.10", + "pytest-html>=4.1.1", + "pytest-metadata>=3.1.1", + "pytest-clarity>=1.0.1", "ruff-lsp<1.0.0,>=0.0.55", "austin-python>=1.7.1", "autoflake>=2.3.1", - "typer>=0.12.5", + "typer>=0.16.0", "pre-commit-uv>=4.1.4", "austin-dist>=3.7.0", "uv>=0.4.25", "deptry>=0.22.0", "sybil[pytest]>=9.0.0", "jsbeautifier<2.0.0,>=1.15.1", - "inflection<1.0.0,>=0.5.1", - "autoflake>=2.3.1", - "black>=24.8.0", - "isort>=5.13.2", - "emoji>=2.14.0", - "pytest-benchmark[histogram]>=5.1.0", - "pytest-asyncio>=0.21.1,<1.0.0", - "loguru>=0.7.3", - "httpx<0.28.2,>=0.28.1", - "jupyterlab>=4.3.5", - "modal>=0.73.25", - "pytest-lsp>=1.0.0b1", - "codegen-api-client>=1.0.0", ] -[tool.uv.workspace] -exclude = ["codegen-examples"] +[tool.hatch.version] +source = "vcs" +raw-options = { version_scheme = "calver-by-date" } + +[tool.hatch.build.hooks.vcs] +version-file = "src/codegen/_version.py" + +[tool.ruff] +target-version = "py310" +line-length = 120 +select = [ + "A", + "B", + "C4", + "C90", + "E", + "F", + "I", + "N", + "PT", + "RUF", + "SIM", + "UP", + "W", +] +ignore = [ + # Allow non-abstract empty methods in abstract base classes + "B027", + # Allow boolean positional values in function calls, like `dict.get(... True)` + "FBT003", + # Ignore checks for possible passwords + "S105", "S106", "S107", + # Ignore complexity + "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", +] +unfixable = [ + # Don't touch unused imports + "F401", +] + +[tool.ruff.isort] +known-first-party = ["codegen"] + +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" +[tool.ruff.per-file-ignores] +# Tests can use magic values, assertions, and relative imports +"tests/**/*" = ["PLR2004", "S101", "TID252"] [tool.coverage.run] +source_pkgs = ["codegen", "tests"] branch = true -concurrency = ["multiprocessing", "thread"] parallel = true -sigterm = true +omit = [ + "src/codegen/__about__.py", +] + +[tool.coverage.paths] +codegen = ["src/codegen", "*/codegen/src/codegen"] +tests = ["tests", "*/codegen/tests"] [tool.coverage.report] -skip_covered = true -skip_empty = true -exclude_also = [ - "if TYPE_CHECKING:", - # Don't complain about missing debug-only code: - "def __repr__", - # Don't complain if tests don't hit defensive assertion code: - "raise AssertionError", - "raise NotImplementedError", - # Don't complain if non-runnable code isn't run: +exclude_lines = [ + "no cov", "if __name__ == .__main__.:", - # Don't complain about abstract methods, they aren't run: - "@(abc\\.)?abstractmethod", + "if TYPE_CHECKING:", ] -[tool.coverage.html] -show_contexts = true -[tool.coverage.json] -show_contexts = true -[tool.pyright] -pythonVersion = "3.12" -enableExperimentalFeatures = true [tool.pytest.ini_options] -# addopts = -v -pythonpath = "." -norecursedirs = "repos expected" -# addopts = -v --cov=app --cov-report=term - -addopts = "--dist=loadgroup --junitxml=build/test-results/test/TEST.xml --strict-config --import-mode=importlib --cov-context=test --cov-config=pyproject.toml -p no:doctest" -filterwarnings = """ - ignore::DeprecationWarning:botocore.*: - ignore::DeprecationWarning:sqlalchemy.*: - ignore::DeprecationWarning:posthog.*:""" -log_cli = true -log_cli_level = "INFO" -xfail_strict = true -junit_duration_report = "call" -junit_logging = "all" -tmp_path_retention_policy = "failed" -asyncio_mode = "auto" -asyncio_default_fixture_loop_scope = "function" -[build-system] -requires = ["hatchling>=1.26.3", "hatch-vcs>=0.4.0", "setuptools-scm>=8.0.0"] -build-backend = "hatchling.build" - - -[tool.deptry] -extend_exclude = [".*/eval/test_files/.*.py", ".*conftest.py"] -pep621_dev_dependency_groups = ["types"] -[tool.deptry.per_rule_ignores] -DEP002 = [ - "hatch-vcs", # Used for version management during build - "hatchling", # Used for building +testpaths = ["tests"] +python_files = "test_*.py" +python_classes = ["Test*"] +python_functions = ["test_*"] +filterwarnings = [ + "ignore::DeprecationWarning:pkg_resources", ] -DEP003 = [] -DEP004 = "pytest" - -[tool.deptry.package_module_name_map] -PyGithub = ["github"] -GitPython = ["git"] -python-dotenv = ["dotenv"] -pydantic-settings = ["pydantic_settings"] -datamodel-code-generator = ["datamodel_code_generator"] -sentry-sdk = ["sentry_sdk"] - - -[tool.semantic_release] -assets = [] -build_command_env = [] -commit_message = "{version}\n\nAutomatically generated by python-semantic-release" -commit_parser = "angular" -logging_use_named_masks = false -major_on_zero = true -allow_zero_version = true -repo_dir = "." -no_git_verify = false -tag_format = "v{version}" - -[tool.semantic_release.branches.develop] -match = "develop" -prerelease_token = "rc" -prerelease = false +