Skip to content

Commit 933a9c5

Browse files
committed
Hugo's regex-fu
1 parent ab4bc95 commit 933a9c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/dataclasses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,12 @@ def _is_type(annotation, cls, a_module, a_type, is_type_predicate):
808808
# https://github.com/python/cpython/issues/77634 for details.
809809
global _MODULE_IDENTIFIER_RE
810810
if _MODULE_IDENTIFIER_RE is None:
811-
_MODULE_IDENTIFIER_RE = re.compile(r'^(?:\s*(\w+)\s*\.)?\s*(\w+)')
811+
_MODULE_IDENTIFIER_RE = re.compile(r'(?:\s*(\w+)\s*\.)?\s*(\w+)')
812812

813-
match = _MODULE_IDENTIFIER_RE.match(annotation)
813+
match = _MODULE_IDENTIFIER_RE.prefixmatch(annotation)
814814
if match:
815815
ns = None
816-
module_name = match.group(1)
816+
module_name = match[1]
817817
if not module_name:
818818
# No module name, assume the class's module did
819819
# "from dataclasses import InitVar".

0 commit comments

Comments
 (0)