8000 [WIP] [Call-by-name] migrate `src/python/pants/engine/internals/build_files.py` by tdyas · Pull Request #22353 · pantsbuild/pants · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[WIP] [Call-by-name] migrate src/python/pants/engine/internals/build_files.py #22353

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tdyas
Copy link
Contributor
@tdyas tdyas commented May 21, 2025

Refactor src/python/pants/engine/internals/build_files.py to call-by-name syntax.

@tdyas tdyas added category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required PR doesn't require mention in release notes labels May 21, 2025
@tdyas tdyas requested review from sureshjoshi and benjyw May 21, 2025 13:22
@tdyas
8000 Copy link
Contributor Author
tdyas commented May 21, 2025

Note: This PR is stacked on top of #22352 which refactors environments-related code to avoid an import cycle which this PR would encounter otherwise.

@tdyas tdyas force-pushed the migrate-call-by-name/internals-build_files branch from eab71af to 73bfd2e Compare May 21, 2025 14:13
@@ -66,6 +66,23 @@

def test_parse_address_family_empty() -> None:
"""Test that parsing an empty BUILD file results in an empty AddressFamily."""

def mock_get_digest_contents(digest) -> DigestContents:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This mock fails with:

E               TypeError: test_extend_synthetic_target.<locals>.mock_get_digest_contents() missing 1 required positional argument: 'digest'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(As does its counterpart in the other test.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@benjyw: Does run_rule_with_mocks properly handle a rule that calls itself recursively?

Copy link
Contributor Author
@tdyas tdyas May 21, 2025

Choose a reason for hiding this comment

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

The issue goes away if I move the heterogeneous await's inside a concurrently out of the concurrently and have them be standalone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The local frame for the Coroutine shows the args parameters to be empty but the __implicitly value to have the parameter:

ipdb> res.cr_frame.f_locals
{'__implicitly': (AddressFamilyDir(path='/dev'),), 'args': (), 'kwargs': {}, 'output_type': <class 'pants.engine.internals.build_files.OptionalAddressFamily'>, 'rule_id': 'pants.engine.internals.build_files.parse_address_family'}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some work in RuleRunner to extract the args from __implicitly which seemed to have helped but still need a way to deal with the dict syntax and matching values in the dict to the mock functions parameters.

@tdyas tdyas marked this pull request as draft May 21, 2025 14:25
@tdyas tdyas changed the title [Call-by-name] migrate src/python/pants/engine/internals/build_files.py [WIP] [Call-by-name] migrate src/python/pants/engine/internals/build_files.py May 21, 2025
Base automatically changed from environments/refactor-target-types to main May 25, 2025 02:56
tobni added a commit that referenced this pull request Jul 3, 2025
Was looking at potential rust port opportunities and got derailed and
changed this. Side note: porting target adapters and build file stuff
seems like a good candidate to use rust and not cache every
intermediate.

Duplicates #22353, sorry!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required PR doesn't require mention in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0