diff --git a/luigi/mypy.py b/luigi/mypy.py index 373e10c9b1..8de6d5a37e 100644 --- a/luigi/mypy.py +++ b/luigi/mypy.py @@ -7,6 +7,7 @@ from __future__ import annotations import re +import sys from typing import Callable, Dict, Final, Iterator, List, Literal, Optional from mypy.expandtype import expand_type, expand_type_by_instance @@ -60,7 +61,13 @@ METADATA_TAG: Final[str] = "task" -PARAMETER_FULLNAME_MATCHER: Final = re.compile(r"^luigi(\.parameter)?\.\w*Parameter$") +PARAMETER_FULLNAME_MATCHER: Final[re.Pattern] = re.compile( + r"^luigi(\.parameter)?\.\w*Parameter$" +) + +if sys.version_info[:2] < (3, 8): + # This plugin uses the walrus operator, which is only available in Python 3.8+ + raise RuntimeError("This plugin requires Python 3.8+") class TaskPlugin(Plugin):