diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index cf13479d1f4..e31a7c26a63 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -305,7 +305,7 @@ def parse(self) -> None: tokens = self.fetch_type_param_spec() tp_ann = self._build_identifier(tokens) - if current == [token.OP, '=']: + if self.current and self.current == [token.OP, '=']: tokens = self.fetch_type_param_spec() tp_default = self._build_identifier(tokens)