-
-
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
Move native options parsing out of the legacy Parser #21652
Conversation
@@ -410,8 +416,47 @@ def for_scope( | |||
:return: An OptionValueContainer representing the option values for the given scope. | |||
:raises pants.option.errors.ConfigValidationError: if the scope is unknown. | |||
""" | |||
builder = OptionValueContainerBuilder() |
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 is all moved verbatim from parser.py.
) | ||
explicitly_set = rank > Rank.HARDCODED | ||
|
||
# If we explicitly set a deprecated but not-yet-expired option, warn about it. |
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.
The one change is that we used to check deprecations twice, once at registration time (but only to catch expired deprecations) and once at parse time. Now we do both in a single check, here, at parse time.
with pytest.raises(CodeRemovedError): | ||
create_options([GLOBAL_SCOPE], register, []) | ||
opts.for_scope(scope=GLOBAL_SCOPE) |
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.
creating options doesn't now trigger the expired deprecation check, we must parse.
@@ -95,7 +91,7 @@ def _invert(cls, s: bool | str | None) -> bool | None: | |||
def __init__(self, scope: str) -> None: | |||
"""Create a Parser instance. | |||
|
|||
:param scope_info: the scope this parser acts for. | |||
:param scope: the scope this parser acts for. |
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 was a leftover docstring error
The Parser class had two jobs:
This change removes the final vestiges of the second, by
inlining them in
options.py
.A future change will rename Parser to, say, Registrar, as
befits its now single remaining role.