diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 41a57e1b4..e147af2bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,10 @@ repos: - id: biome-check additional_dependencies: ["@biomejs/biome@1.9.4"] exclude: (src/codemods/eval)|(tests/unit/skills/snapshots)|(tests/unit/codegen/sdk/output)|(tests/integration/verified_codemods)|(docs/samples) - + - repo: https://github.com/ComPWA/taplo-pre-commit + rev: v0.9.3 + hooks: + - id: taplo-format - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.16.6 hooks: diff --git a/hatch.toml b/hatch.toml index 33fa2eb1f..0b1d7737f 100644 --- a/hatch.toml +++ b/hatch.toml @@ -12,9 +12,9 @@ tool = ["uv", "pip"] [envs.hatch-build.overrides] matrix.tool.installer = { value = "{matrix:tool}" } matrix.tool.scripts = [ - { key = "pip", value = "{env:HATCH_UV} pip {args}", if = [ - "uv", - ] }, + { key = "pip", value = "{env:HATCH_UV} pip {args}", if = [ + "uv", + ] }, ] [version] @@ -25,19 +25,19 @@ UV_EXTRA_INDEX_URL = "https://aws@codegen-922078275900.d.codeartifact.us-east-1. [build.targets.wheel.hooks.cython] dependencies = [ - "hatch-cython @ git+https://github.com/codegen-sh/hatch-cython.git", - "cython>=3.0.11", - "tree-sitter", - "networkx", + "hatch-cython @ git+https://github.com/codegen-sh/hatch-cython.git", + "cython>=3.0.11", + "tree-sitter", + "networkx", ] [build.targets.wheel.hooks.cython.options] src = "codegen/sdk" compile_args = [ - "-O3", - { platforms = [ - "darwin", - ], arch = "arm64", arg = "-mcpu=apple-m1" }, + "-O3", + { platforms = [ + "darwin", + ], arch = "arm64", arg = "-mcpu=apple-m1" }, ] cythonize_kwargs = { annotate = true, nthreads = 16, exclude_failures = false, cache = true } compiled_sdist = true @@ -57,27 +57,30 @@ c_string_type = "unicode" [build.targets.wheel.hooks.cython.options.files] exclude = [ - "**/__init__.py", - "**/code_generation", - "**/skills", - "**/codebase/factory", - "**/guides", - "**/testing", - "**/codebase_graph_utils.py", + "**/__init__.py", + "**/code_generation", + "**/skills", + "**/codebase/factory", + "**/guides", + "**/testing", + "**/codebase_graph_utils.py", ] [build.targets.wheel] macos-max-compat = false [build] -packages = [ - "src/codegen", -] - -[metadata.hooks.vcs] -Homepage = "https://github.com/codegen-sh/codegen-sdk" -source_archive = "https://github.com/codegen-sh/codegen-sdk/archive/{commit_hash}.zip" +packages = ["src/codegen"] +[metadata.hooks.vcs.urls] +Homepage = "https://www.codegen.com/" +Repository = "https://github.com/codegen-sh/codegen-sdk" +download = "https://github.com/codegen-sh/codegen-sdk/archive/{commit_hash}.zip" +Changelog = "https://docs.codegen.com/changelog/changelog" +Releasenotes = "https://github.com/codegen-sh/codegen-sdk/releases" +Issues = "https://github.com/codegen-sh/codegen-sdk/issues" +Documentation = "https://docs.codegen.sh" +Playground = "https://www.codegen.sh/" [build.targets.wheel.hooks.custom] enable-by-default = false diff --git a/pyproject.toml b/pyproject.toml index 848f46b64..d32e379d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,112 +1,144 @@ [project] name = "codegen" dynamic = ["version", "urls"] -description = "Add your description here" +description = "A python library for manipulating codebases" readme = "README.md" # renovate: datasource=python-version depName=python requires-python = ">=3.12, <3.14" dependencies = [ - "backoff==2.2.1", - "openai==1.59.9", - "tiktoken<1.0.0,>=0.5.1", - "tabulate>=0.9.0,<1.0.0", - "codeowners<1.0.0,>=0.6.0", - "dataclasses-json<1.0.0,>=0.6.4", - "dicttoxml<2.0.0,>=1.7.16", - "xmltodict<1.0.0,>=0.13.0", - "astor<1.0.0,>=0.8.1", - "tree-sitter>=0.23.1", - "tree-sitter-python>=0.23.4", - "tree-sitter-typescript>=0.23.2", - "tree-sitter-javascript>=0.23.1", - "python-levenshtein<1.0.0,>=0.25.1", - "networkx>=3.4.1", - "wrapt<2.0.0,>=1.16.0", - "pyright<2.0.0,>=1.1.372", - "watchfiles<1.1.0,>=1.0.0", - "rich<14.0.0,>=13.7.1", - "pydantic<3.0.0,>=2.9.2", - "docstring-parser<1.0,>=0.16", - "plotly<6.0.0,>=5.24.0", - "humanize<5.0.0,>=4.10.0", - "pytest-snapshot>=0.9.0", - "anthropic==0.23.1", - "pyjson5==1.6.8", - "mini-racer>=0.12.4", - "rustworkx>=0.15.1", - "typing-extensions>=4.12.2", - "termcolor>=2.4.0", - "sentry-sdk==2.20.0", - "tenacity>=9.0.0", - "click>=8.1.7", - "requests>=2.32.3", - "lazy-object-proxy>=0.0.0", - "pydantic-core>=2.23.4", - "hatch-vcs>=0.4.0", - "hatchling>=1.25.0", - "pyinstrument>=5.0.0", - "pip>=24.3.1", # This is needed for some NPM/YARN/PNPM post-install scripts to work! - "rich-click>=1.8.5", - "python-dotenv>=1.0.1", - "giturlparse", - "pygit2>=1.16.0", - "unidiff>=0.7.5", - "datamodel-code-generator>=0.26.5", - "toml>=0.10.2", - "PyGithub==2.5.0", - "GitPython==3.1.44", - "psutil>=5.8.0", - "fastapi[standard]<1.0.0,>=0.115.2", - "starlette<1.0.0,>=0.16.0", - "tqdm>=4.67.1", + "backoff==2.2.1", + "openai==1.59.9", + "tiktoken<1.0.0,>=0.5.1", + "tabulate>=0.9.0,<1.0.0", + "codeowners<1.0.0,>=0.6.0", + "dataclasses-json<1.0.0,>=0.6.4", + "dicttoxml<2.0.0,>=1.7.16", + "xmltodict<1.0.0,>=0.13.0", + "astor<1.0.0,>=0.8.1", + "tree-sitter>=0.23.1", + "tree-sitter-python>=0.23.4", + "tree-sitter-typescript>=0.23.2", + "tree-sitter-javascript>=0.23.1", + "python-levenshtein<1.0.0,>=0.25.1", + "networkx>=3.4.1", + "wrapt<2.0.0,>=1.16.0", + "pyright<2.0.0,>=1.1.372", + "watchfiles<1.1.0,>=1.0.0", + "rich<14.0.0,>=13.7.1", + "pydantic<3.0.0,>=2.9.2", + "docstring-parser<1.0,>=0.16", + "plotly<6.0.0,>=5.24.0", + "humanize<5.0.0,>=4.10.0", + "pytest-snapshot>=0.9.0", + "anthropic==0.23.1", + "pyjson5==1.6.8", + "mini-racer>=0.12.4", + "rustworkx>=0.15.1", + "typing-extensions>=4.12.2", + "termcolor>=2.4.0", + "sentry-sdk==2.20.0", + "tenacity>=9.0.0", + "click>=8.1.7", + "requests>=2.32.3", + "lazy-object-proxy>=0.0.0", + "pydantic-core>=2.23.4", + "hatch-vcs>=0.4.0", + "hatchling>=1.25.0", + "pyinstrument>=5.0.0", + "pip>=24.3.1", # This is needed for some NPM/YARN/PNPM post-install scripts to work! + "rich-click>=1.8.5", + "python-dotenv>=1.0.1", + "giturlparse", + "pygit2>=1.16.0", + "unidiff>=0.7.5", + "datamodel-code-generator>=0.26.5", + "toml>=0.10.2", + "PyGithub==2.5.0", + "GitPython==3.1.44", + "psutil>=5.8.0", + "fastapi[standard]<1.0.0,>=0.115.2", + "starlette<1.0.0,>=0.16.0", + "tqdm>=4.67.1", ] -license = {file = "LICENSE"} + +license = { text = "Apache-2.0" } classifiers = [ - "License :: OSI Approved :: Apache Software License", -"Intended Audience :: Developers", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Topic :: Software Development", "Development Status :: 4 - Beta", "Environment :: MacOS X", "Programming Language :: Python :: 3", "Programming Language :: Python", ] + "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", + + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "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", +] +authors = [{ name = "Codegen Team", email = "team+codegenbot@codegen.sh" }] +keywords = [ + "codegen", + "codebase", + "codebase manipulation", + "codebase analysis", + "codebase transformation", + "refactoring", + "code generation", + "code generation", + "codebase analysis", + "codebase transformation", + "refactoring", +] [project.scripts] codegen = "codegen.cli.cli:main" [project.optional-dependencies] -types = [ - "types-networkx>=3.2.1.20240918", - "types-tabulate>=0.9.0.20240106", -] +types = ["types-networkx>=3.2.1.20240918", "types-tabulate>=0.9.0.20240106"] [tool.uv] cache-keys = [{ git = { commit = true, tags = true } }] dev-dependencies = [ - "coverage<8.0.0,>=7.6.1", - # "scalene>=1.5.45", - "filelock<4.0.0,>=3.15.4", - "pytest>=8.3.3", - "pytest-cov>=6.0.0,<6.0.1", - "ruff>=0.6.8", - "mypy[mypyc,faster-cache]>=1.13.0", - "pre-commit>=4.0.1", - "pytest-xdist>=3.6.1,<4.0.0", - "pytest-mock<4.0.0,>=3.14.0", - "pytest-timeout>=2.3.1", - "braintrust>=0.0.160", - "ruff-lsp<1.0.0,>=0.0.55", - "austin-python>=1.7.1", - "autoflake>=2.3.1", - # "nuitka>=2.4.8", - "keyrings-codeartifact>=1.3.3", - "typer>=0.12.5", - "pre-commit-uv>=4.1.4", - "austin-dist>=3.7.0", - "uv>=0.4.25", - "cython>=3.0.11", - "deptry>=0.22.0", - "cibuildwheel[uv]>=2.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", + "coverage<8.0.0,>=7.6.1", + # "scalene>=1.5.45", + "filelock<4.0.0,>=3.15.4", + "pytest>=8.3.3", + "pytest-cov>=6.0.0,<6.0.1", + "ruff>=0.6.8", + "mypy[mypyc,faster-cache]>=1.13.0", + "pre-commit>=4.0.1", + "pytest-xdist>=3.6.1,<4.0.0", + "pytest-mock<4.0.0,>=3.14.0", + "pytest-timeout>=2.3.1", + "braintrust>=0.0.160", + "ruff-lsp<1.0.0,>=0.0.55", + "austin-python>=1.7.1", + "autoflake>=2.3.1", + # "nuitka>=2.4.8", + "keyrings-codeartifact>=1.3.3", + "typer>=0.12.5", + "pre-commit-uv>=4.1.4", + "austin-dist>=3.7.0", + "uv>=0.4.25", + "cython>=3.0.11", + "deptry>=0.22.0", + "cibuildwheel[uv]>=2.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", ] keyring-provider = "subprocess" #extra-index-url = ["https://aws@codegen-922078275900.d.codeartifact.us-east-1.amazonaws.com/pypi/codegen/simple/"] @@ -120,41 +152,41 @@ max-line-length = 200 [tool.ruff] line-length = 200 exclude = [ - "app/codemod/compilation/function_imports.py", # generated import list to compile uesr code with - 'codegen_tests/**/expected*/**', - 'codegen_tests/**/original/**', - 'codegen_tests/projects/**/codebase/**', - 'docs/**', - 'scripts/Debugging/**', + "app/codemod/compilation/function_imports.py", # generated import list to compile uesr code with + 'codegen_tests/**/expected*/**', + 'codegen_tests/**/original/**', + 'codegen_tests/projects/**/codebase/**', + 'docs/**', + 'scripts/Debugging/**', ] lint.select = ["F", "E", "W", "I", "UP", "D", "RUF", "DTZ"] lint.ignore = [ - "D100", - "D101", - "D102", - "D103", - "D104", - "D105", - "D106", - "D107", - "D203", - "D205", - "D213", - "D400", - "D401", - "D402", - "D404", - "D415", - "D417", - "E712", # https://github.com/astral-sh/ruff/issues/4560 - "F841", - "F842", - "RUF012", - "RUF007", + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", + "D203", + "D205", + "D213", + "D400", + "D401", + "D402", + "D404", + "D415", + "D417", + "E712", # https://github.com/astral-sh/ruff/issues/4560 + "F841", + "F842", + "RUF012", + "RUF007", ] lint.exclude = [ - "*.ipynb", + "*.ipynb", ] # disable just linting for notebooks (allow for formatting) lint.pydocstyle.convention = "google" [tool.ruff.lint.isort] @@ -172,16 +204,16 @@ sigterm = true 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: - "if __name__ == .__main__.:", - # Don't complain about abstract methods, they aren't run: - "@(abc\\.)?abstractmethod", + "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: + "if __name__ == .__main__.:", + # Don't complain about abstract methods, they aren't run: + "@(abc\\.)?abstractmethod", ] [tool.coverage.html] @@ -198,7 +230,7 @@ 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-report=json --cov-config=pyproject.toml -p no:doctest" -filterwarnings =""" +filterwarnings = """ ignore::DeprecationWarning:botocore.*: ignore::DeprecationWarning:sqlalchemy.*: ignore::DeprecationWarning:posthog.*:""" @@ -209,14 +241,27 @@ junit_duration_report = "call" junit_logging = "all" [build-system] -requires = ["hatchling>=1.26.3", "hatch-vcs>=0.4.0", "setuptools-scm>=8.0.0"] +requires = [ + "hatchling>=1.26.3", + "hatch-vcs>=0.4.0", + "setuptools-scm>=8.0.0", + "setuptools>=75.8.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 = ["pyright", "mini-racer", "hatch-vcs", "pyinstrument", "pip", "python-levenshtein", "pytest-snapshot"] +DEP002 = [ + "pyright", + "mini-racer", + "hatch-vcs", + "pyinstrument", + "pip", + "python-levenshtein", + "pytest-snapshot", +] DEP003 = "sqlalchemy" DEP004 = "pytest" @@ -226,6 +271,6 @@ PyGithub = ["github"] [tool.cibuildwheel] build-frontend = "build[uv]" skip = ["*-musllinux_i686", "*-manylinux_i686", "*-musllinux_x86_64"] -environment = { "HATCH_BUILD_HOOKS_ENABLE"="true" } -manylinux-x86_64-image="quay.io/pypa/manylinux_2_34_x86_64" -manylinux-aarch64-image="quay.io/pypa/manylinux_2_34_aarch64" +environment = { "HATCH_BUILD_HOOKS_ENABLE" = "true" } +manylinux-x86_64-image = "quay.io/pypa/manylinux_2_34_x86_64" +manylinux-aarch64-image = "quay.io/pypa/manylinux_2_34_aarch64"