8000 Import underlying parser functions as an underscored variable (#663) · pypa/packaging@5b34465 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b34465

Browse files
authored
Import underlying parser functions as an underscored variable (#663)
These functions are not a part of the public interface for the modules they're being imported into. Co-authored-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
1 parent 7013a60 commit 5b34465

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/packaging/markers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
import sys
99
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
1010

11-
from ._parser import MarkerAtom, MarkerList, Op, Value, Variable, parse_marker
11+
from ._parser import (
12+
MarkerAtom,
13+
MarkerList,
14+
Op,
15+
Value,
16+
Variable,
17+
parse_marker as _parse_marker,
18+
)
1219
from ._tokenizer import ParserSyntaxError
1320
from .specifiers import InvalidSpecifier, Specifier
1421
from .utils import canonicalize_name
@@ -189,7 +196,7 @@ def __init__(self, marker: str) -> None:
189196
# packaging.requirements.Requirement. If any additional logic is
190197
# added here, make sure to mirror/adapt Requirement.
191198
try:
192-
self._markers = _normalize_extra_values(parse_marker(marker))
199+
self._markers = _normalize_extra_values(_parse_marker(marker))
193200
# The attribute `_markers` can be described in terms of a recursive type:
194201
# MarkerList = List[Union[Tuple[Node, ...], str, MarkerList]]
195202
#

src/packaging/requirements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import urllib.parse
66
from typing import Any, List, Optional, Set
77

8-
from ._parser import parse_requirement
8+
from ._parser import parse_requirement as _parse_requirement
99
from ._tokenizer import ParserSyntaxError
1010
from .markers import Marker, _normalize_extra_values
1111
from .specifiers import SpecifierSet
@@ -32,7 +32,7 @@ class Requirement:
3232

3333
def __init__(self, requirement_string: str) -> None:
3434
try:
35-
parsed = parse_requirement(requirement_string)
35+
parsed = _parse_requirement(requirement_string)
3636
except ParserSyntaxError as e:
3737
raise InvalidRequirement(str(e)) from e
3838

0 commit comments

Comments
 (0)
0