Skip to content

Commit 94f736a

Browse files
author
Teryl Taylor
committed
fix: linted memory.py, added assertion to test.
1 parent b70ca3f commit 94f736a

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

cpex/framework/memory.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import copy
1515
import logging
1616
import weakref
17+
from collections.abc import Mapping
1718
from typing import Any, Iterator, Optional, TypeVar
1819

1920
# Third-Party
@@ -189,16 +190,13 @@ def __eq__(self, other: Any) -> bool:
189190
True if other is a Mapping with the same key-value pairs, False otherwise.
190191
Returns NotImplemented for non-Mapping types to allow other.__eq__ to handle it.
191192
"""
192-
# Import here to avoid circular dependency
193-
from collections.abc import Mapping
194-
195193
if not isinstance(other, Mapping):
196194
return NotImplemented
197-
195+
198196
# Fast-path: if lengths differ, mappings cannot be equal
199197
if len(self) != len(other):
200198
return False
201-
199+
202200
# Compare materialized items
203201
return dict(self.items()) == dict(other.items())
204202

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ preview = true
146146
fixable = ["ALL"]
147147
unfixable = []
148148

149+
[tool.ruff.lint.pylint]
150+
# Relaxed from the default of 5; existing code has wider try clauses (max observed 38).
151+
max-statements-in-try = 50
152+
149153
# Ignore D1 (docstring checks) and Pylint checks in tests and other non-production code
150154
[tool.ruff.lint.per-file-ignores]
151155
"tests/**/*.py" = ["D1", "PL"]

tests/unit/cpex/framework/test_memory.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ def test_equality_with_different_dict(self):
840840
assert cow != {"a": 1, "b": 3}
841841
assert cow != {"a": 1}
842842
assert cow != {"a": 1, "b": 2, "c": 3}
843+
# Same length, different keys
844+
assert cow != {"a": 1, "c": 2}
843845

844846
def test_equality_after_modifications(self):
845847
"""Equality should reflect modifications."""

0 commit comments

Comments
 (0)