Skip to content

Commit 3cf11df

Browse files
committed
Remove unnecessary recursion guard
1 parent eba9b25 commit 3cf11df

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tests/conftest.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,8 @@ def __getattr__(self, name: str) -> object: # numpydoc ignore=PR01,RT01
6969
def _wrap(func: Callable[P, T]) -> Callable[P, T]: # numpydoc ignore=PR01,RT01
7070
"""Wrap func to make all np.ndarrays it returns read-only."""
7171

72-
def as_readonly(o: T, seen: set[int]) -> T: # numpydoc ignore=PR01,RT01
72+
def as_readonly(o: T) -> T: # numpydoc ignore=PR01,RT01
7373
"""Unset the writeable flag in o."""
74-
if id(o) in seen:
75-
return o
76-
seen.add(id(o))
77-
7874
try:
7975
# Don't use is_numpy_array(o), as it includes np.generic
8076
if isinstance(o, np.ndarray):
@@ -85,13 +81,13 @@ def as_readonly(o: T, seen: set[int]) -> T: # numpydoc ignore=PR01,RT01
8581

8682
# This works with namedtuples too
8783
if isinstance(o, tuple | list):
88-
return type(o)(*(as_readonly(i, seen) for i in o)) # type: ignore[arg-type,return-value] # pyright: ignore[reportArgumentType,reportUnknownArgumentType]
84+
return type(o)(*(as_readonly(i) for i in o)) # type: ignore[arg-type,return-value] # pyright: ignore[reportArgumentType,reportUnknownArgumentType]
8985

9086
return o
9187

9288
@wraps(func)
9389
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: # numpydoc ignore=GL08
94-
return as_readonly(func(*args, **kwargs), seen=set())
90+
return as_readonly(func(*args, **kwargs))
9591

9692
return wrapper
9793

0 commit comments

Comments
 (0)