Ruff rules S, SIM, SLOT#126
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
✅ Files skipped from review due to trivial changes (4)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughRefactors simplify conditional and membership expressions across engine, utilities, and tests, add a document-type guard before document comparisons, replace a try/except with contextlib.suppress, and expand Ruff lint rules; behavior and public interfaces are unchanged. ChangesCode Simplification and Quality Improvements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
montydb/engine/weighted.py (1)
87-93:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winFix
__slots__incompatibility that preventsWeightedinstantiation.The
__slots__ = ()declaration on the tuple subclass prevents theself.value = valueassignment in__init__. WhenWeighted(v)is instantiated (line 567 incollection.py), it will raiseAttributeError: 'Weighted' object has no attribute 'value'. This breaks thedistinct()method which depends on accessing.valueat line 583.Either remove the
__slots__ = ()declaration or remove theself.value = valueassignment. If the value storage is necessary, consider an alternative approach that doesn't conflict with the empty slots.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@montydb/engine/weighted.py` around lines 87 - 93, The Weighted tuple subclass currently sets __slots__ = () which prevents assigning an instance attribute in __init__ and causes AttributeError when instantiating Weighted(value); fix by removing or altering the __slots__ declaration so instance attribute storage is allowed, or by eliminating self.value and instead rely on the tuple contents (e.g., access the stored value via tuple indexing) — update the class Weighted (its __slots__, __new__, and __init__ methods and usages of .value) and ensure callers (e.g., distinct()) read the value from the adjusted representation (either instance attribute or tuple element) consistently.
🧹 Nitpick comments (1)
pyproject.toml (1)
71-71: ⚡ Quick winConsider scoping
S101to test files only.
S101warns against usingassertstatements because they can be optimized away withpython -O. Currently, it's globally ignored, which meansassertstatements are allowed throughout the codebase, including production code.Consider moving
S101toper-file-ignoresto allow asserts only in test files:🔒 Suggested configuration to scope S101 to tests
ignore = [ - "S101", "SIM102", "UP015", ] per-file-ignores = { "montydb/storage/sqlite.py" = [ "SIM117" ], + "tests/**/*.py" = [ "S101" ], }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pyproject.toml` at line 71, The project currently ignores the S101 Flake8 rule globally in pyproject.toml (entry "S101"), which allows use of assert in production; update pyproject.toml to remove "S101" from the global ignores and instead add it under per-file-ignores scoped to your test files (e.g., add an entry under [tool.flake8].per-file-ignores mapping test/* or tests/* to "S101") so asserts remain allowed only in test modules; ensure the per-file-ignores key and the exact pattern (tests/* or test_*.py) match your test layout and keep other existing ignores intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@montydb/engine/weighted.py`:
- Around line 87-93: The Weighted tuple subclass currently sets __slots__ = ()
which prevents assigning an instance attribute in __init__ and causes
AttributeError when instantiating Weighted(value); fix by removing or altering
the __slots__ declaration so instance attribute storage is allowed, or by
eliminating self.value and instead rely on the tuple contents (e.g., access the
stored value via tuple indexing) — update the class Weighted (its __slots__,
__new__, and __init__ methods and usages of .value) and ensure callers (e.g.,
distinct()) read the value from the adjusted representation (either instance
attribute or tuple element) consistently.
---
Nitpick comments:
In `@pyproject.toml`:
- Line 71: The project currently ignores the S101 Flake8 rule globally in
pyproject.toml (entry "S101"), which allows use of assert in production; update
pyproject.toml to remove "S101" from the global ignores and instead add it under
per-file-ignores scoped to your test files (e.g., add an entry under
[tool.flake8].per-file-ignores mapping test/* or tests/* to "S101") so asserts
remain allowed only in test modules; ensure the per-file-ignores key and the
exact pattern (tests/* or test_*.py) match your test layout and keep other
existing ignores intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8debbaa1-0f8e-4d7e-b8f5-01c778aaab23
📒 Files selected for processing (13)
montydb/engine/field_walker.pymontydb/engine/project.pymontydb/engine/queries.pymontydb/engine/update.pymontydb/engine/weighted.pymontydb/types/objectid.pymontydb/utils/io.pypyproject.tomltests/test_client.pytests/test_database.pytests/test_engine/conftest.pytests/test_engine/test_fieldwalker/test_fieldwalker_set.pytests/test_packaging.py
f164f21 to
83a7209
Compare
83a7209 to
5323011
Compare
Summary by CodeRabbit
Bug Fixes
Refactor
Tests
Chores