fixtures: fix a typing ignore TODO
From understanding the code better I see this is the correct fix. The fixturedefs can be None if `request.getfixturevalue("doesnotexist")` is used. In practice there is no change in behavior because this mapping is used as `self._arg2fixturedefs.get(argname, None)` which ends up the same.
This commit is contained in:
parent
2c80de532f
commit
ecfab4dc8b
|
@ -464,12 +464,13 @@ class FixtureRequest:
|
|||
assert self._pyfuncitem.parent is not None
|
||||
parentid = self._pyfuncitem.parent.nodeid
|
||||
fixturedefs = self._fixturemanager.getfixturedefs(argname, parentid)
|
||||
# TODO: Fix this type ignore. Either add assert or adjust types.
|
||||
# Can this be None here?
|
||||
self._arg2fixturedefs[argname] = fixturedefs # type: ignore[assignment]
|
||||
if fixturedefs is not None:
|
||||
self._arg2fixturedefs[argname] = fixturedefs
|
||||
if fixturedefs is None:
|
||||
raise FixtureLookupError(argname, self)
|
||||
# fixturedefs list is immutable so we maintain a decreasing index.
|
||||
index = self._arg2index.get(argname, 0) - 1
|
||||
if fixturedefs is None or (-index > len(fixturedefs)):
|
||||
if -index > len(fixturedefs):
|
||||
raise FixtureLookupError(argname, self)
|
||||
self._arg2index[argname] = index
|
||||
return fixturedefs[index]
|
||||
|
|
Loading…
Reference in New Issue