@@ -171,22 +171,30 @@ def getfixturemarker(obj: object) -> FixtureFunctionMarker | None:
171171
172172
173173@dataclasses .dataclass (frozen = True )
174- class FixtureArgKey :
174+ class ParamArgKey :
175+ """A key for a high-scoped parameter used by an item.
176+
177+ For use as a hashable key in `reorder_items`. The combination of fields
178+ is meant to uniquely identify a particular "instance" of a param,
179+ potentially shared by multiple items in a scope.
180+ """
181+
182+ #: The param name.
175183 argname : str
176184 param_index : int
185+ #: For scopes Package, Module, Class, the path to the file (directory in
186+ #: Package's case) of the package/module/class where the item is defined.
177187 scoped_item_path : Path | None
188+ #: For Class scope, the class where the item is defined.
178189 item_cls : type | None
179190
180191
181192_V = TypeVar ("_V" )
182193OrderedSet = dict [_V , None ]
183194
184195
185- def get_parametrized_fixture_argkeys (
186- item : nodes .Item , scope : Scope
187- ) -> Iterator [FixtureArgKey ]:
188- """Return list of keys for all parametrized arguments which match
189- the specified scope."""
196+ def get_param_argkeys (item : nodes .Item , scope : Scope ) -> Iterator [ParamArgKey ]:
197+ """Return all ParamArgKeys for item matching the specified high scope."""
190198 assert scope is not Scope .Function
191199
192200 try :
@@ -212,19 +220,17 @@ def get_parametrized_fixture_argkeys(
212220 if callspec ._arg2scope [argname ] != scope :
213221 continue
214222 param_index = callspec .indices [argname ]
215- yield FixtureArgKey (argname , param_index , scoped_item_path , item_cls )
223+ yield ParamArgKey (argname , param_index , scoped_item_path , item_cls )
216224
217225
218226def reorder_items (items : Sequence [nodes .Item ]) -> list [nodes .Item ]:
219- argkeys_by_item : dict [Scope , dict [nodes .Item , OrderedSet [FixtureArgKey ]]] = {}
220- items_by_argkey : dict [
221- Scope , dict [FixtureArgKey , OrderedDict [nodes .Item , None ]]
222- ] = {}
227+ argkeys_by_item : dict [Scope , dict [nodes .Item , OrderedSet [ParamArgKey ]]] = {}
228+ items_by_argkey : dict [Scope , dict [ParamArgKey , OrderedDict [nodes .Item , None ]]] = {}
223229 for scope in HIGH_SCOPES :
224230 scoped_argkeys_by_item = argkeys_by_item [scope ] = {}
225231 scoped_items_by_argkey = items_by_argkey [scope ] = defaultdict (OrderedDict )
226232 for item in items :
227- argkeys = dict .fromkeys (get_parametrized_fixture_argkeys (item , scope ))
233+ argkeys = dict .fromkeys (get_param_argkeys (item , scope ))
228234 if argkeys :
229235 scoped_argkeys_by_item [item ] = argkeys
230236 for argkey in argkeys :
@@ -240,9 +246,9 @@ def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]:
240246
241247def reorder_items_atscope (
242248 items : OrderedSet [nodes .Item ],
243- argkeys_by_item : Mapping [Scope , Mapping [nodes .Item , OrderedSet [FixtureArgKey ]]],
249+ argkeys_by_item : Mapping [Scope , Mapping [nodes .Item , OrderedSet [ParamArgKey ]]],
244250 items_by_argkey : Mapping [
245- Scope , Mapping [FixtureArgKey , OrderedDict [nodes .Item , None ]]
251+ Scope , Mapping [ParamArgKey , OrderedDict [nodes .Item , None ]]
246252 ],
247253 scope : Scope ,
248254) -> OrderedSet [nodes .Item ]:
@@ -252,7 +258,7 @@ def reorder_items_atscope(
252258 scoped_items_by_argkey = items_by_argkey [scope ]
253259 scoped_argkeys_by_item = argkeys_by_item [scope ]
254260
255- ignore : set [FixtureArgKey ] = set ()
261+ ignore : set [ParamArgKey ] = set ()
256262 items_deque = deque (items )
257263 items_done : OrderedSet [nodes .Item ] = {}
258264 while items_deque :
0 commit comments