Skip to content

Commit

Permalink
Use recursive types in _parser
Browse files Browse the repository at this point in the history
This makes use of more accurate type checking enabled by newer type
checker versions.
  • Loading branch information
pradyunsg committed Mar 10, 2024
1 parent 2975921 commit 4223a24
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/packaging/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

import ast
from typing import Any, List, NamedTuple, Tuple, Union
from typing import NamedTuple, Sequence, Tuple, Union

from ._tokenizer import DEFAULT_RULES, Tokenizer

Expand Down Expand Up @@ -43,12 +43,8 @@ def serialize(self) -> str:

MarkerVar = Union[Variable, Value]
MarkerItem = Tuple[MarkerVar, Op, MarkerVar]
# MarkerAtom = Union[MarkerItem, List["MarkerAtom"]]
# MarkerList = List[Union["MarkerList", MarkerAtom, str]]
# mypy does not support recursive type definition
# https://github.com/python/mypy/issues/731
MarkerAtom = Any
MarkerList = List[Any]
MarkerAtom = Union[MarkerItem, Sequence["MarkerAtom"]]
MarkerList = Sequence[Union["MarkerList", MarkerAtom, str]]


class ParsedRequirement(NamedTuple):
Expand Down

0 comments on commit 4223a24

Please sign in to comment.