Skip to content

style(ruff): enable B912 check and add strict=False to map calls - #248

Merged
schwehr merged 1 commit into
mainfrom
ruff-b912
Sep 25, 2026
Merged

schwehr merged 1 commit into
mainfrom
ruff-b912

Conversation

@schwehr

@schwehr schwehr commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Code Review & Suggestions for Improvement

  1. Adopt strict=True for Equal-Length Vector Operations:
    • In boolean operations such as __xor__, __and__, __or__ (and their in-place equivalents), self.vector and bv2.vector are expected to have the same number of words after padding/resizing.
    • Changing strict=False to strict=True for these operations would catch any silent truncations or unexpected array size mismatches earlier as an explicit ValueError.
  2. Replace map(...) with List/Generator Comprehensions or Vectorized Word Operations:
    • In methods like shift_left_by_one and shift_right_by_one, repeated construction of temporary lists ([1] * size, [63] * size) and multiple map() calls create unnecessary memory allocations. A single list comprehension or direct
      word loop across self.vector would be clearer and faster.
  3. Enable B905 (zip-without-explicit-strict):
    • Similarly to B912, B905 is currently in the ignore list in pyproject.toml:79. Enabling B905 and adding explicit strict= arguments to zip() calls would further improve safety and consistency across the codebase.

Copilot AI lite review requested due to automatic review settings September 25, 2026 03:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

A remaining map() call will fail the enabled B912 lint check, and boolean operations should use strict=True.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Updates Ruff configuration to enable B912 and adds explicit strict=False arguments to map() calls.

Changes:

  • Removes B912 from Ruff’s ignore list.
  • Adds explicit map strictness to BitVector operations.
  • Leaves B905 ignored and one map() call without strict=.
File Summary
pyproject.toml Enables B912 linting; B905 remains ignored.
BitVector/​BitVector.py Updates map calls, but leaves one B912 violation and uses non-strict boolean operations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pyproject.toml
@@ -78,7 +78,6 @@ select = ["ALL"]
ignore = [
"ANN001", # missing-type-function-argument
"ANN401", # any-type
Comment thread pyproject.toml
"ANN001", # missing-type-function-argument
"ANN401", # any-type
"B912", # map-without-explicit-strict
"B905", # zip-without-explicit-strict
@schwehr
schwehr merged commit 1a8c6a0 into main Sep 25, 2026
9 checks passed
@schwehr
schwehr deleted the ruff-b912 branch September 25, 2026 03:34
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