-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Support strong first-party declarations of provided types #13698
Support strong first-party declarations of provided types #13698
Conversation
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
This code specifically resolves the ambiguity by having the third-party mapping return no results for |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
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.
Should the field be on java_source
and when the field is present on java_sources
then Pants figures out how to "split" it to only the java_source
target that defines the type?
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
If we wanted to be technically correct, then yes, I guess? I didn't go looking particularly hard for how the first party symbol map works in relation to target generation, but I suspect we'd need the symbol map to be run first. I'm not sure that's doable. On the other hand, all that To prevent spurious use of the field, we may want to consider verifying that all of the (cc @tdyas) |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
^--- And the above is exactly what I've done now. |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
def __init__(self): | ||
self.children: dict[str, MutableTrieNode] = {} | ||
self.recursive: bool = False | ||
self.addresses: OrderedSet[Address] = OrderedSet() | ||
self.first_party: bool = False |
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.
If we end up having the !
syntax for packages
, we may want to redefine this field for more complicated exclusions, but for now, this will do.
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.
Agreed.
The results from first party and third party symbol matching are merged together (and then checked for ambiguity). The order in which they are evaluated does not matter. |
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.
Should this PR just be implemented by implementing negation support in the trie? Is there a benefit to supporting first_party as a concept in the trie now versus changing it to be implemented via general negation support later?
def __init__(self): | ||
self.children: dict[str, MutableTrieNode] = {} | ||
self.recursive: bool = False | ||
self.addresses: OrderedSet[Address] = OrderedSet() | ||
self.first_party: bool = False |
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.
Agreed.
src/python/pants/jvm/target_types.py
Outdated
@@ -64,6 +64,11 @@ class JvmArtifactPackagesField(StringSequenceField): | |||
) | |||
|
|||
|
|||
class JvmProvidesTypesField(StringSequenceField): | |||
alias = "experimental_provides_types" | |||
help = "TODO: Add help for this." |
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.
Still needs to be filled in.
@tdyas Re supporting negation in the trie: I think we may need to map out a proper design for how to implement negation properly. I think there are actually two concepts that matter to here:
With that in mind, I'd prefer to punt on redesigning that, until we implement negation as a more general concept, so we can flesh out the design better. |
Makes sense. Agreed. |
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.
lgtm subject to any open comments
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
This reverts commit a27e44e. [ci skip-rust] [ci skip-build-wheels]
Adds a new field to
java_source
(s
) andscala_source
(s
) targets that allow them to strongly declare that they provide a specific JVM type. This excludes these types from being provided by third-party dep inference. This allows first-party sources to provide types that amend a third-party package.TODO: remove
exampleapp
amendmentCloses #13661