Skip to content

AT-14951: migrate from pylint/isort/black to ruff - #34

Merged
jconstance-amplify merged 2 commits into
mainfrom
AT-14951-migrate_to_ruff
Jul 16, 2026
Merged

AT-14951: migrate from pylint/isort/black to ruff#34
jconstance-amplify merged 2 commits into
mainfrom
AT-14951-migrate_to_ruff

Conversation

@jconstance-amplify

Copy link
Copy Markdown

Summary

  • Swapped isort (8.0.1), black (26.3.1), and pylint (v4.0.5, local hook) in .pre-commit-config.yaml for a single astral-sh/ruff-pre-commit hook at v0.15.21 (ruff-check --fix + ruff-format) — one tool instead of three separately-versioned ones. mypy is untouched.
  • Added pyproject.toml with [tool.ruff]: line-length = 120 (from this repo's pylintrc max-line-length, not black's unset/88 default), target-version = "py311" (from default_language_version.python and the tox.ini envlist), and [tool.ruff.lint] select = ["E", "W", "F", "I"] (pycodestyle + pyflakes + import-sort, matching the minimal set the migration template uses — no broader rule opt-in).
  • Removed pylintrc. Left inline # pylint: disable=E1120 comments in oktaawscli/okta_awscli.py alone — that rule code has no equivalent in the new minimal select set, so it's inert, not broken.
  • Updated CONTRIBUTING.md's PR-acceptance instructions, which previously told contributors to run pylint --errors-only oktaawscli; now points at pre-commit run --all-files.
  • Left .travis.yml alone — it's dead Travis-era CI (Python 3.6.5, and the README's build badges point at the upstream author's travis-ci.org/jmhale/... project, which no longer exists). Live CI is .github/workflows/pr_check.yml (pre-commit + tox), unaffected by this migration.

Hand-fixed findings (ruff-check --fix didn't cover)

  • F401 in oktaawscli/__init__.py: from .version import __version__ was flagged as an unused import. This is a deliberate public re-export (oktaawscli.__version__), not a mistake, so fixed with ruff's own suggested explicit re-export form: from .version import __version__ as __version__.
  • No E721 (type(x) == y) findings in this repo.
  • No E501-inside-string-literal findings. Two comment lines contain long URLs (>120 chars) but ruff's E501 — like pycodestyle's — exempts unsplittable single-token overflows (URLs with no whitespace), so these are correctly not flagged; no rewrap needed.
  • Checked for the # type: ignore/# noqa detach trap: the repo's one such comment (oktaawscli/okta_auth_config.py:10) sits on a line the reflow didn't touch; mypy passes cleanly.
  • Checked for orphaned comments left behind by an F401 auto-fix: none found.

Note on scope

An initial pass also bumped oktaawscli/version.py to 0.4.17 and added a CHANGELOG.md entry, following this repo's own CONTRIBUTING.md convention ("increment the version... document your changes in CHANGELOG"). This was reverted in a follow-up commit after checking the reference pilot migration (amplify-education/expeditor-api-v2#536) — it doesn't touch version/changelog files either, and this repo's own CHANGELOG documents that version bumps here are wired to an automated CodeArtifact publish. A pure lint-tool swap with no behavior change shouldn't trigger a release, so the migration was kept purely mechanical, consistent with the pilot and the already-merged batch.

Reference template PRs: cookiecutter-amplify-python #18, cookiecutter-amplify-python-lambda okta-awscli#123.

Test plan

  • pre-commit run --all-files — clean (ruff-check, ruff-format, mypy, and all other existing hooks pass)
  • tox (python -m unittest discover -s tests -v -b) — 30/30 tests pass
  • Diffed the reformatted .py files by hand to confirm all changes are 88→120 line-length reflow / import-sort churn with no logic changes (multi-context-manager with statements were reformatted into parenthesized form, which ruff-format supports for target-version = py311+)

🤖 Generated with Claude Code

jconstance-amplify and others added 2 commits July 16, 2026 09:15
Swap isort, black, and pylint in .pre-commit-config.yaml for a single
astral-sh/ruff-pre-commit hook (ruff-check --fix, ruff-format), per
AT-14951 (astrotools-owned apps migrating off the three-tool lint
stack). One tool instead of three separately-versioned ones, same
formatting behavior as black plus isort's import-sort rules folded in.

- pyproject.toml: new [tool.ruff] block, line-length=120 (from this
  repo's pylintrc max-line-length, not black's unset/88 default) and
  target-version="py311" (from default_language_version/tox envlist).
- Removed pylintrc; left inline `# pylint: disable=...` comments alone
  since their rule codes have no equivalent in the minimal E/W/F/I
  select set.
- Hand-fixed one ruff-check finding pylint's --fix didn't cover:
  F401 in oktaawscli/__init__.py (`from .version import __version__`)
  needed an explicit re-export alias (`as __version__`) since it's a
  deliberate public re-export, not a mistaken unused import.
- Updated CONTRIBUTING.md's pylint-specific PR-acceptance instructions
  to point at `pre-commit run --all-files` instead.
- Left .travis.yml alone: it's dead Travis-era CI (python 3.6.5,
  badges point at the upstream author's travis-ci.org project); live
  CI is .github/workflows/pr_check.yml (pre-commit + tox), unaffected.
- Bumped version to 0.4.17 and logged the change in CHANGELOG.md per
  this repo's CONTRIBUTING.md convention.

Verified: `pre-commit run --all-files` clean (ruff-check, ruff-format,
mypy all pass) and `tox` (30 unit tests) passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Revert the 0.4.17 version bump and CHANGELOG entry from the previous
commit. The verified pilot (expeditor-api-v2 PR #536) and the batch of
already-merged repos don't touch version/changelog files for this
migration — it's a pure lint-tool swap with zero behavior change, and
this package's own CHANGELOG shows version bumps here trigger an
automated CodeArtifact publish, which isn't warranted for a tooling-
only diff.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jconstance-amplify
jconstance-amplify marked this pull request as ready for review July 16, 2026 20:00
@jconstance-amplify
jconstance-amplify requested a review from a team as a code owner July 16, 2026 20:00
@jconstance-amplify
jconstance-amplify merged commit b5b3da0 into main Jul 16, 2026
1 check passed
@jconstance-amplify
jconstance-amplify deleted the AT-14951-migrate_to_ruff branch July 16, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants