From 208638323c3c6326c85f704e0133d93859c8984e Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Thu, 14 Jul 2022 13:24:16 -0700 Subject: [PATCH] Update src/_pytest/fixtures.py Co-authored-by: Ran Benita --- src/_pytest/fixtures.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 4975be820..d1d36d7fa 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -407,6 +407,14 @@ class FixtureRequest: self._arg2fixturedefs = fixtureinfo.name2fixturedefs.copy() self._arg2index: Dict[str, int] = {} self._fixturemanager: FixtureManager = pyfuncitem.session._fixturemanager + # Notes on the type of `param`: + # -`request.param` is only defined in parametrized fixtures, and will raise + # AttributeError otherwise. Python typing has no notion of "undefined", so + # this cannot be reflected in the type. + # - Technically `param` is only (possibly) defined on SubRequest, not + # FixtureRequest, but the typing of that is still in flux so this cheats. + # - In the future we might consider using a generic for the param type, but + # for now just using Any. self.param: Any @property