Skip to content

Commit 8d815ca

Browse files
committed
python: type some CallSpec2 fields as immutable
Knowing that a field is immutable makes it easier to understand the code.
1 parent 8032d21 commit 8d815ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/_pytest/python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,9 @@ class CallSpec2:
11231123
# arg name -> arg index.
11241124
indices: Dict[str, int] = dataclasses.field(default_factory=dict)
11251125
# Used for sorting parametrized resources.
1126-
_arg2scope: Dict[str, Scope] = dataclasses.field(default_factory=dict)
1126+
_arg2scope: Mapping[str, Scope] = dataclasses.field(default_factory=dict)
11271127
# Parts which will be added to the item's name in `[..]` separated by "-".
1128-
_idlist: List[str] = dataclasses.field(default_factory=list)
1128+
_idlist: Sequence[str] = dataclasses.field(default_factory=tuple)
11291129
# Marks which will be applied to the item.
11301130
marks: List[Mark] = dataclasses.field(default_factory=list)
11311131

@@ -1141,7 +1141,7 @@ def setmulti(
11411141
) -> "CallSpec2":
11421142
params = self.params.copy()
11431143
indices = self.indices.copy()
1144-
arg2scope = self._arg2scope.copy()
1144+
arg2scope = dict(self._arg2scope)
11451145
for arg, val in zip(argnames, valset):
11461146
if arg in params:
11471147
raise ValueError(f"duplicate parametrization of {arg!r}")

0 commit comments

Comments
 (0)