Skip to content

docs: add a B034 keyword-argument example - #641

Merged
cooperlees merged 2 commits into
PyCQA:mainfrom
jaesungkr:docs/b034-keyword-examples
Nov 18, 2026
Merged

cooperlees merged 2 commits into
PyCQA:mainfrom
jaesungkr:docs/b034-keyword-examples

Conversation

@jaesungkr

Copy link
Copy Markdown
Contributor

Add a compact Avoid/Prefer example for B034 and a link to the existing tests.

Passing re.IGNORECASE as the fourth positional argument to re.sub supplies count, not flags. The example shows the resulting AAA output and the intended bbb output when using flags=re.IGNORECASE.

This only changes README documentation. It does not change the checker or its diagnostics.

Refs #620 (B034 only; this does not complete the broader examples issue).

Validation

  • Extracted and executed the README example on Python 3.11–3.15: expected outputs and exactly one B034 diagnostic on Avoid, none on Prefer.
  • tox suites: Python 3.11 (157 passed, 9 skipped), 3.12 (158 passed, 8 skipped), 3.13 (159 passed, 7 skipped), 3.14 (163 passed, 3 skipped), 3.15 (166 passed).
  • pep8-naming, strict mypy on Python 3.11/3.15, all pre-commit hooks, and strict RST rendering passed.
  • Isolated sdist/wheel builds, strict twine metadata checks, and git diff whitespace checks passed. Remote CI has not run.

AI assistance

I worked on the implementation and validation with assistance from AI.

Add a compact Avoid/Prefer example and existing-test link.
Refs PyCQA#620; documentation only.

AI assistance was used to prepare the documentation and validation.

@cooperlees cooperlees left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was written by Claude (Anthropic's AI assistant) on behalf of @cooperlees.

Thanks @jaesungkr. It's a clear, compact example that picks the exact trap B034 exists to catch.

What I checked

  • The example is correct. re.IGNORECASE == 2, so in the "Avoid" line it becomes count=2 and the match stays case-sensitive. Nothing in "AAA" matches "a", so it prints AAA. The "Prefer" line prints bbb. I ran both locally.
  • It follows the format already used for B032 and the other documented rules: # Avoid: / # Prefer: comments, the expected output in a trailing comment, and a More examples: link. The linked tests/eval_files/b034.py exists.
  • The change is README-only. CI and pre-commit are green.

Optional nit: on Python 3.13+, the "Avoid" line also emits DeprecationWarning: 'count' is passed as positional argument. That backs up the rule, so a short mention could be a nice touch, but it isn't needed.

Approving.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cooperlees
cooperlees merged commit 327431f into PyCQA:main Nov 18, 2026
6 checks passed
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