Skip to content

chore: pin black/isort/flake8 to modern versions - #833

Merged
qiyanjun merged 3 commits into
masterfrom
chore/upgrade-black-version
Aug 14, 2026
Merged

qiyanjun merged 3 commits into
masterfrom
chore/upgrade-black-version

Conversation

@qiyanjun

Copy link
Copy Markdown
Member

Summary

  • black==20.8b1 (pinned since 2020) depends on typed_ast, which fails to build on Python >=3.10 — nobody on a current Python can install the version make lint/CI enforces, so local devs lint with whatever newer black they have, which silently disagrees with CI on formatting edge cases (see Fix six more issues from the unresolved-bugs backlog #831's CI failure on textattack/shared/validators.py).
  • Bump black to 25.11.0, isort to 6.1.0, flake8 to 7.3.0 — all verified to install cleanly on Python 3.9 (matching the Formatting with black & isort CI job).
  • Add pyproject.toml with [tool.black] line-length/target-version so the config itself is locked, not just the version.
  • Drop the click<8.1.0 workaround in check-formatting.yml, which was only needed for the old black pin.
  • Reformat the repo once with the new pinned toolchain — mechanical only (docstring rewrapping, black's newer paren-splitting style), no logic changes.

Test plan

  • make format + make lint run clean against a fresh Python 3.9 env with the exact pinned versions
  • Spot-checked the larger diffs (e.g. particle_swarm_optimization.py) to confirm changes are purely cosmetic
  • ast.parse sanity check on every changed .py file
  • CI green on this PR

🤖 Generated with Claude Code

qiyanjun and others added 3 commits August 14, 2026 01:27
black==20.8b1 depended on typed_ast, which fails to build on Python
>=3.10, so nobody on a current Python could install the version CI
enforced (make lint) -- local devs ended up linting with whatever
newer black they had, which silently disagrees with CI on formatting
edge cases. isort==5.6.4 had the same staleness problem.

Bump to black==25.11.0, isort==6.1.0, flake8==7.3.0 (all verified to
install cleanly on Python 3.9, matching the lint CI job), add a
pyproject.toml pinning black's line-length/target-version so the
config itself doesn't drift, and drop the click<8.1.0 workaround that
was only needed for the old black pin. Reformat the repo once with
the new pinned toolchain (mechanical only: docstring rewrapping,
black's newer paren-splitting style -- no logic changes).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
textattack/=22.3.0 was accidental debris: an unquoted
`pip install black>=22.3.0` got parsed by the shell as a redirect
into a file literally named =22.3.0, and the resulting stray file was
gitignored instead of deleted. The file itself is long gone; drop the
leftover ignore rule.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
black==25.11.0, isort==6.1.0, and flake8==7.3.0 (pinned in this PR) all
require Python>=3.9, so pip install -e .[dev] was silently unresolvable
on Python 3.8 despite setup.py still advertising 3.8 support. Also drop
py38 from black's target-version in pyproject.toml to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@qiyanjun
qiyanjun merged commit 88b6fcc into master Aug 14, 2026
6 checks passed
qiyanjun added a commit that referenced this pull request Aug 14, 2026
ReadTheDocs builds have been failing near-instantly (~2s, a
config-level failure, not a real Sphinx error) since setup.py's
python_requires was bumped to >=3.9 (PR #833). Two problems:

- build.os was pinned to ubuntu-20.04, which ReadTheDocs has since
  deprecated.
- build.tools.python was pinned to "3.8", which no longer satisfies
  textattack's own python_requires >=3.9 when the docs build installs
  the package itself (python.install's `path: .` entry).

Bumped to ubuntu-24.04 / Python 3.11, matching what
.github/workflows/make-docs.yml already uses successfully in CI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant