Skip to content

Commit

Permalink
Remove dead code from Marker.evaluate()
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMino committed May 18, 2022
1 parent b94b8e7 commit 21d6058
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions packaging/markers.py
Expand Up @@ -202,24 +202,6 @@ def _eval_op(lhs: str, op: Op, rhs: str) -> bool:
return oper(lhs, rhs)


class Undefined:
pass


_undefined = Undefined()


def _get_env(environment: Dict[str, str], name: str) -> str:
value: Union[str, Undefined] = environment.get(name, _undefined)

if isinstance(value, Undefined):
raise UndefinedEnvironmentName(
f"{name!r} does not exist in evaluation environment."
)

return value


def _normalize(*values: str, key: str) -> Tuple[str, ...]:
# PEP 685 – Comparison of extra names for optional distribution dependencies
# https://peps.python.org/pep-0685/
Expand All @@ -245,12 +227,12 @@ def _evaluate_markers(markers: List[Any], environment: Dict[str, str]) -> bool:

if isinstance(lhs, Variable):
environment_key = lhs.value
lhs_value = _get_env(environment, environment_key)
lhs_value = environment[environment_key]
rhs_value = rhs.value
else:
lhs_value = lhs.value
environment_key = rhs.value
rhs_value = _get_env(environment, environment_key)
rhs_value = environment[environment_key]

lhs_value, rhs_value = _normalize(lhs_value, rhs_value, key=environment_key)
groups[-1].append(_eval_op(lhs_value, op, rhs_value))
Expand Down

0 comments on commit 21d6058

Please sign in to comment.