From 4bbbc215977b2bfb9f95521f841f917bf4f46e77 Mon Sep 17 00:00:00 2001 From: Mridul Sahu Date: Fri, 29 May 2026 13:26:15 -0700 Subject: [PATCH] Simplify linting setup to relax errors on PRs. PiperOrigin-RevId: 923573264 --- .python-version => .github-python-version | 0 .github/workflows/lint.yml | 8 ++++---- .pre-commit-config.yaml | 22 +++++----------------- .pylintrc | 11 ++++------- CONTRIBUTING.md | 1 - pyproject.toml | 22 ---------------------- 6 files changed, 13 insertions(+), 51 deletions(-) rename .python-version => .github-python-version (100%) diff --git a/.python-version b/.github-python-version similarity index 100% rename from .python-version rename to .github-python-version diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 58bfba55c..63cbf11b3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,15 +15,15 @@ jobs: if: github.actor != 'copybara-service[bot]' steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - # This reads from .python-version (the minimum Python version that Orbax supports). - python-version-file: '.python-version' + # This reads from .github-python-version (the minimum Python version that Orbax supports). + python-version-file: '.github-python-version' cache: 'pip' - name: Install Pre-commit and PyType diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07040ee8c..83ab65071 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,11 @@ # pre-commit configuration for Orbax. -# Run locally with: pre-commit run --all-files +# Run locally with: pre-commit run --files $(git diff --name-only origin/main) # -# Tool config lives in the repo-root pyproject.toml ([tool.pyink], -# [tool.isort]) and .pylintrc. The --config / --settings-path arguments -# below force the hooks to read from the root instead of the closest -# subpackage pyproject.toml (checkpoint/, model/, export/). +# Tool config lives in the repo-root pyproject.toml ([tool.isort]) and +# .pylintrc. The --settings-path / --rcfile arguments below force the hooks +# to read from the root instead of the closest subpackage pyproject.toml +#(checkpoint/, model/, export/). repos: - - repo: https://github.com/google/pyink - rev: '25.12.0' - hooks: - - id: pyink - types_or: [python, jupyter] - files: '\.(py|ipynb)$' - args: [--config=pyproject.toml] - additional_dependencies: ["pyink[jupyter]"] - - repo: https://github.com/pylint-dev/pylint rev: v4.0.5 hooks: @@ -24,7 +15,6 @@ repos: verbose: true args: - --rcfile=.pylintrc - exclude: ^(tests/|.*_test\.py$) - repo: https://github.com/PyCQA/isort rev: 6.0.1 @@ -33,7 +23,6 @@ repos: name: isort types: [python] args: [--settings-path=pyproject.toml] - exclude: ^(tests/|.*_test\.py$) - repo: https://github.com/google/pytype rev: '2024.10.11' @@ -41,4 +30,3 @@ repos: - id: pytype name: pytype args: [-d, import-error, --keep-going, -j, auto] - exclude: ^(tests/|.*_test\.py$) diff --git a/.pylintrc b/.pylintrc index faba4d7d2..518286b28 100644 --- a/.pylintrc +++ b/.pylintrc @@ -37,11 +37,6 @@ extension-pkg-whitelist= [PARAMETER_DOCUMENTATION] -accept-no-param-doc=yes -accept-no-return-doc=yes -accept-no-yields-doc=yes -accept-no-raise-doc=yes - # Default docstring format. default-docstring-type=google @@ -86,6 +81,7 @@ disable=apply-builtin, consider-refactoring-into-while-condition, consider-ternary-expression, consider-using-any-or-all, + consider-using-assignment-expr, consider-using-augmented-assign, consider-using-dict-comprehension, consider-using-dict-items, @@ -125,6 +121,7 @@ disable=apply-builtin, input-builtin, intern-builtin, invalid-str-codec, + isinstance-second-argument-not-valid-type, locally-disabled, long-builtin, long-suffix, @@ -269,7 +266,7 @@ method-rgx=(?x)^(?:(?P_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase # Regular expression which should only match function or class names that do # not require a docstring. -no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$ +no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test|_.*)$ # Minimum line length for functions/classes that require docstrings, shorter # ones are exempt. @@ -307,7 +304,7 @@ generated-members= [FORMAT] # Maximum number of characters on a single line. -max-line-length=80 +max-line-length=125 # TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt # lines made too long by directives to pytype. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c2e1bb21..712347f48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,6 @@ enforce it, wired together through the | Tool | Role | Config | |---|---|---| -| [`pyink`](https://github.com/google/pyink) | Formatter (Black fork with Google defaults) | `[tool.pyink]` in `pyproject.toml` | | [`pylint`](https://pylint.readthedocs.io/) | Linter | `.pylintrc` | | [`isort`](https://pycqa.github.io/isort/) | Import order | `[tool.isort]` in `pyproject.toml` | | [`pytype`](https://github.com/google/pytype) | Static Type Inferece & Verification | `.pre-commit-config.yaml` | diff --git a/pyproject.toml b/pyproject.toml index 49c62e798..2f4e60ae5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,28 +3,6 @@ # under checkpoint/, model/, and export/. Only formatter/linter settings live # here so they apply uniformly across the monorepo. -[tool.pyink] -line-length = 80 -unstable = false -target-version = [] -pyink-indentation = 2 -pyink-use-majority-quotes = true -pyink-annotation-pragmas = [ - "noqa", - "pylint:", - "type: ignore", - "pytype:", - "mypy:", - "pyright:", - "pyre-", - "@title", - "@param", - "@markdown", - "@tidy", - "@test", -] -pyink-ipynb-indentation = 2 - [tool.isort] profile = "google" known_third_party = ["orbax"]