Skip to content
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

Improvements and refactoring of help system. #10280

Merged
merged 5 commits into from Jul 7, 2020

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Jul 7, 2020

Previously the HelpFormatter, HelpPrinter and HelpInfoExtracter were rather
entangled. This change:

  • Fully detaches these concepts: The HelpInfoExtracter now produces an
    instance of a new AllHelpInfo class, containing all help information,
    including scope descriptions. The HelpPrinter/HelpFormatter operate
    exclusively on this data. They no longer need access to an Options instance,
    let alone a HelpInfoExtractor.
  • Displays related subsystems in the help output for a goal.
  • Distinguishes the stringified option default from the original typed default value.
  • Switches some help-related dataclass fields to be tuples instead of lists.
  • Various other improvements.

[ci skip-rust-tests]

# Rust tests will be skipped. Delete if not intended.
[ci skip-rust-tests]
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

src/python/pants/help/help_formatter_test.py Outdated Show resolved Hide resolved
src/python/pants/help/help_printer.py Show resolved Hide resolved
src/python/pants/option/arg_splitter.py Outdated Show resolved Hide resolved
deprecation_version: Optional[str]
details: Optional[str]


# TODO: Get rid of this? The parser should be able to lazily track.
class OptionTracker:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this v1 only?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never 100% understood this class, because I thought that the RankedValue container would be able to record where things had come from. But have never looked deeply.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RankedValue is just a single value attached to a Rank, it doesn't know about any other values.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there's probably some simplification we can do. E.g., the RankedValue can carry the "details" information (e.g., which config file a CONFIG-level value came from)

Copy link
Sponsor Member

@stuhood stuhood Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but it is inside an OptionValueContainer, which does have all of them, I thought? EDIT: But looking at it now, it's just a dict. Ok.

benjyw and others added 2 commits July 7, 2020 12:29
# Rust tests will be skipped. Delete if not intended.
[ci skip-rust-tests]
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great cleanup!

src/python/pants/init/engine_initializer.py Show resolved Hide resolved
deprecation_version: Optional[str]
details: Optional[str]


# TODO: Get rid of this? The parser should be able to lazily track.
class OptionTracker:
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never 100% understood this class, because I thought that the RankedValue container would be able to record where things had come from. But have never looked deeply.

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
@benjyw benjyw merged commit 02a2d32 into pantsbuild:master Jul 7, 2020
@benjyw benjyw deleted the help_improvements branch July 7, 2020 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants