Skip to content

Commit

Permalink
Import underlying parser functions as an underscored variable (#663)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pradyunsg and pradyunsg committed Feb 13, 2023
1 parent 7013a60 commit 5b34465
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/packaging/markers.py
Expand Up @@ -8,7 +8,14 @@
import sys
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from ._parser import MarkerAtom, MarkerList, Op, Value, Variable, parse_marker
from ._parser import (
MarkerAtom,
MarkerList,
Op,
Value,
Variable,
parse_marker as _parse_marker,
)
from ._tokenizer import ParserSyntaxError
from .specifiers import InvalidSpecifier, Specifier
from .utils import canonicalize_name
Expand Down Expand Up @@ -189,7 +196,7 @@ def __init__(self, marker: str) -> None:
# packaging.requirements.Requirement. If any additional logic is
# added here, make sure to mirror/adapt Requirement.
try:
self._markers = _normalize_extra_values(parse_marker(marker))
self._markers = _normalize_extra_values(_parse_marker(marker))
# The attribute `_markers` can be described in terms of a recursive type:
# MarkerList = List[Union[Tuple[Node, ...], str, MarkerList]]
#
Expand Down
4 changes: 2 additions & 2 deletions src/packaging/requirements.py
Expand Up @@ -5,7 +5,7 @@
import urllib.parse
from typing import Any, List, Optional, Set

from ._parser import parse_requirement
from ._parser import parse_requirement as _parse_requirement
from ._tokenizer import ParserSyntaxError
from .markers import Marker, _normalize_extra_values
from .specifiers import SpecifierSet
Expand All @@ -32,7 +32,7 @@ class Requirement:

def __init__(self, requirement_string: str) -> None:
try:
parsed = parse_requirement(requirement_string)
parsed = _parse_requirement(requirement_string)
except ParserSyntaxError as e:
raise InvalidRequirement(str(e)) from e

Expand Down

0 comments on commit 5b34465

Please sign in to comment.