-
-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rip out more parts of the legacy parser #21643
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ | |||||||||
import inspect | ||||||||||
import itertools | ||||||||||
import json | ||||||||||
import re | ||||||||||
from collections import defaultdict, namedtuple | ||||||||||
from dataclasses import dataclass | ||||||||||
from enum import Enum | ||||||||||
|
@@ -41,17 +42,19 @@ | |||||||||
from pants.engine.rules import Rule, TaskRule | ||||||||||
from pants.engine.target import Field, RegisteredTargetTypes, StringField, Target, TargetGenerator | ||||||||||
from pants.engine.unions import UnionMembership, UnionRule, is_union | ||||||||||
from pants.option.native_options import NativeOptionParser | ||||||||||
from pants.option.native_options import NativeOptionParser, parse_dest | ||||||||||
from pants.option.option_util import is_dict_option, is_list_option | ||||||||||
from pants.option.options import Options | ||||||||||
from pants.option.parser import OptionValueHistory, Parser | ||||||||||
from pants.option.ranked_value import Rank, RankedValue | ||||||||||
from pants.option.scope import ScopeInfo | ||||||||||
from pants.option.scope import GLOBAL_SCOPE, ScopeInfo | ||||||||||
from pants.util.frozendict import LazyFrozenDict | ||||||||||
from pants.util.strutil import first_paragraph, strval | ||||||||||
|
||||||||||
T = TypeVar("T") | ||||||||||
|
||||||||||
_ENV_SANITIZER_RE = re.compile(r"[.-]") | ||||||||||
|
||||||||||
|
||||||||||
class HelpJSONEncoder(json.JSONEncoder): | ||||||||||
"""Class for JSON-encoding help data (including option values). | ||||||||||
|
@@ -1106,9 +1109,16 @@ def get_option_help_info(self, args, kwargs): | |||||||||
removal_hint = kwargs.get("removal_hint") | ||||||||||
choices = self.compute_choices(kwargs) | ||||||||||
|
||||||||||
dest = Parser.parse_dest(*args, **kwargs) | ||||||||||
dest = parse_dest(*args, **kwargs) | ||||||||||
# Global options have three env var variants. The last one is the most human-friendly. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
maybe port these from the comment since its being deleted |
||||||||||
env_var = Parser.get_env_var_names(self._scope, dest)[-1] | ||||||||||
udest = dest.upper() | ||||||||||
if self._scope == GLOBAL_SCOPE: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is (simplified) logic moved from parser.py. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for my information: we take only the last element, so we can discard the logic that computes the other values |
||||||||||
if udest.startswith("PANTS_"): | ||||||||||
env_var = udest | ||||||||||
else: | ||||||||||
env_var = f"PANTS_{udest}" | ||||||||||
else: | ||||||||||
env_var = f"PANTS_{_ENV_SANITIZER_RE.sub('_', self._scope.upper())}_{udest}" | ||||||||||
|
||||||||||
target_field_name = f"{self._scope_prefix}_{option_field_name_for(args)}".replace("-", "_") | ||||||||||
environment_aware = kwargs.get("environment_aware") is True | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is now the only place using this, so it moved here from parser.py