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

Fix fmt and lint re-runs under pantsd #9869

Merged
merged 3 commits into from May 26, 2020

Conversation

stuhood
Copy link
Sponsor Member

@stuhood stuhood commented May 26, 2020

Problem

The FmtFieldSets and LinterFieldSets types extended Collection (which implements useful eq/hash), but then added an additional optional field, prior_formatter_result. But that additional field was not included in the eq/hash for the type, and this meant that instances of these objects would be equal regardless of the previous result. This resulted in pantsd memoizing the wrong input for runs: in short, havoc.

Solution

Extract StyleRequest to replace FmtFieldSets and LinterFieldSets, and fix __eq__ for that type by extending dataclass. Additionally, align all Fmt and Lint FieldSets types around the name Request.

Result

Operation of fmt and lint is correct under pantsd.

[ci skip-rust-tests]
[ci skip-jvm-tests]

@stuhood
Copy link
Sponsor Member Author

stuhood commented May 26, 2020

Sorry: the first commit definitely should have been two.

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.

Awesome! Glad to see this code get simplified. Thanks!

src/python/pants/core/goals/style.py Outdated Show resolved Hide resolved
src/python/pants/core/goals/style.py Outdated Show resolved Hide resolved
src/python/pants/core/goals/lint_test.py Outdated Show resolved Hide resolved
src/python/pants/core/goals/lint.py Outdated Show resolved Hide resolved
src/python/pants/core/goals/lint.py Outdated Show resolved Hide resolved
src/python/pants/core/goals/lint.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/lint/isort/rules.py Outdated Show resolved Hide resolved
…fix `__eq__` for that type by extending dataclass to include all members in equality.

[ci skip-rust-tests]
[ci skip-jvm-tests]
# Delete this line to force CI to run Clippy and the Rust tests.
[ci skip-rust-tests]
# Delete this line to force CI to run the JVM tests.
[ci skip-jvm-tests]
# Delete this line to force CI to run Clippy and the Rust tests.
[ci skip-rust-tests]
# Delete this line to force CI to run the JVM tests.
[ci skip-jvm-tests]
@stuhood stuhood force-pushed the stuhood/fmt-field-sets-equals branch from 9986123 to 4aeefb5 Compare May 26, 2020 17:16
requests.append(all_source_files_request)
requirements_pex, specified_source_files, *rest = cast(
Union[Tuple[Pex, SourceFiles], Tuple[Pex, SourceFiles, SourceFiles]],
await MultiGet(requests),
)

all_source_files_snapshot = (
request.field_sets.prior_formatter_result
if request.field_sets.prior_formatter_result
request.request.prior_formatter_result
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, hm. This is weird naming. It'd be great to rename the parameter to setup_request and rename the property SetupRequest.request to SetupRequest.docformatter_request. Ditto on Black and Isort.

@stuhood stuhood merged commit 8d95788 into pantsbuild:master May 26, 2020
@stuhood stuhood deleted the stuhood/fmt-field-sets-equals branch May 26, 2020 18:38
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

2 participants