Skip to content

Comments

Expand ruff lint rules and rename make targets (chk→lint, fmt→format)#687

Merged
laughingman7743 merged 2 commits intomasterfrom
refactor/expand-ruff-lint-rules
Feb 22, 2026
Merged

Expand ruff lint rules and rename make targets (chk→lint, fmt→format)#687
laughingman7743 merged 2 commits intomasterfrom
refactor/expand-ruff-lint-rules

Conversation

@laughingman7743
Copy link
Member

@laughingman7743 laughingman7743 commented Feb 22, 2026

Summary

  • Add 11 new ruff lint rule categories: UP (pyupgrade), PIE, PERF, T20, FLY, ISC, RSE, RUF, PGH, G, PT
  • Rename make chkmake lint, make fmtmake format across Makefile, CLAUDE.md, and docs
  • Fix all violations across 138 files (net -173 lines), achieving 0 errors on make lint (ruff check + ruff format + mypy)

Key changes

  • Type annotations: Modernize UnionX | Y, OptionalX | None (UP007)
  • Logging: Convert f-string logging to lazy % formatting (G004/G003)
  • Type safety: Replace blanket # type: ignore with specific error codes like [arg-type], [override] (PGH003)
  • Class attributes: Add ClassVar for mutable class-level constants; use # noqa: RUF012 for SQLAlchemy-inherited attributes
  • Test quality: Add match= to pytest.raises(ValueError) (PT011), extract setup from raises blocks (PT012), use tuple for parametrize names (PT006)
  • Code modernization: yield from (UP028), collection unpacking (RUF005), remove unused imports (F401)
  • Framework conventions: Per-file-ignores for SQLAlchemy naming (N802, N801), PEP 249 required names (B027, N818)

Logic changes (non-cosmetic)

Most changes are cosmetic (import cleanup, comment changes, annotation syntax). The following are the only changes that affect runtime or test behavior:

File Change Risk
pyathena/polars/result_set.py:683 for batch in ...: yield batchyield from ... (UP028) None — semantically identical
pyathena/arrow/result_set.py:193 [ISO8601] + self._timestamp_parsers[ISO8601, *self._timestamp_parsers] (RUF005) None — produces the same list
pyathena/pandas/util.py:292 Added type annotation list[concurrent.futures.Future[Any]] to futures variable None — annotation only, no runtime effect
pyathena/pandas/result_set.py:371 Added # noqa: PERF203 to intentional try-except-in-loop None — comment only
pyathena/s3fs/result_set.py:20 Union[type[...], type[...]]type[...] | type[...] with from __future__ import annotations None — string annotation, no runtime effect
9 files (G004/G003) _logger.info(f"msg {var}")_logger.info("msg %s", var) None — same output; lazy formatting avoids string interpolation when log level is disabled
tests/pyathena/sqlalchemy/test_compiler.py Moved stmt = select(...) before with pytest.raises(...) block (PT012) None — same test logic, setup moved outside context manager
4 test files (PT011) Added match= parameter to pytest.raises(ValueError) Low — makes assertions stricter (tests will catch the right ValueError)
tests/pyathena/test_cursor.py "query,description"("query", "description") in parametrize (PT006) None — equivalent pytest syntax
tests/pyathena/aio/test_cursor.py, tests/pyathena/aio/s3fs/test_cursor.py rows = []; async for row in cursor: rows.append(row)rows = [row async for row in cursor] (PERF401) None — semantically identical

Test plan

  • make lint passes cleanly (ruff check, ruff format --check, mypy)
  • make test passes
  • make test-sqla passes

🤖 Generated with Claude Code

laughingman7743 and others added 2 commits February 22, 2026 21:39
Add 11 new ruff lint rule categories (UP, PIE, PERF, T20, FLY, ISC, RSE,
RUF, PGH, G, PT) and fix all violations across the codebase. Key changes:

- Rename `make chk` to `make lint` in Makefile, CLAUDE.md, and docs
- Modernize type annotations (Union → X|Y, Optional → X|None)
- Convert f-string logging to lazy % formatting (G004/G003)
- Replace blanket `# type: ignore` with specific error codes (PGH003)
- Add ClassVar annotations for mutable class attributes (RUF012)
- Add match parameters to pytest.raises(ValueError) calls (PT011)
- Extract setup from pytest.raises blocks (PT012)
- Use tuple for pytest.mark.parametrize names (PT006)
- Replace yield-for-loop with yield from (UP028)
- Use collection unpacking instead of concatenation (RUF005)
- Add per-file-ignores for SQLAlchemy naming conventions (N802, N801)
- Suppress PEP 249 required names that conflict with lint rules (B027, N818)
- Exclude benchmarks directory from ruff checking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@laughingman7743 laughingman7743 changed the title Expand ruff lint rules and rename make chk to make lint Expand ruff lint rules and rename make targets (chk→lint, fmt→format) Feb 22, 2026
@laughingman7743 laughingman7743 marked this pull request as ready for review February 22, 2026 13:21
@laughingman7743 laughingman7743 merged commit 8530dca into master Feb 22, 2026
15 checks passed
@laughingman7743 laughingman7743 deleted the refactor/expand-ruff-lint-rules branch February 22, 2026 13:21
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