In a __dependencies_rules__ declaration, I tried t...
# general
c
In a __dependencies_rules__ declaration, I tried to use the example given in the docs, {"type": python_sources}, but the parsing breaks with an error of "TypeError: decoding to str: need a bytes-like object, Registrar found", I need to enclose python_sources in quotes. Am I doing something wrong? Also, I can't use a catch_all rule spec ({}, "*"), it says target must not be empty.
f
thanks for sharing this, sorry for the trouble, IIRC @curved-television-6568 has fixed this so that you can use the string or a target name - it just hasn't been included in 2.16.0; could you please try with a later version, if that's at all possible? I struggle to find an exact PR, but I think this should make it to the 2.17.0
Also, I can't use a catch_all rule spec ({}, "*"), it says target must not be empty.
would you please share the ruleset you have and the error output? This should help us troubleshoot
c
I tried with 2.17.0rc1 and it was the same. The ruleset is basically the one int he example from the docs,
# src/a/BUILD  (continued from previous example)
__dependencies_rules__(
(
{"type": python_sources},  # We can use the target type unquoted when we don't need glob syntax
"src/a/**",  # May depend on anything from src/a/
"src/b/lib.py",  # May depend on specific file
"!*",  # May not depend on anything else. This is our "catch all" rule, ensuring there will never be any fall-through, which would've been an error
),
# We need another rule set, in case we have non-python sources in here, to avoid fall-through.
# Sticking in a generic catch-all allow-all rule.
({}, "*"),
)
f
right. I looked at my rules and I've used
("*", "*"),
and I think this should have the same effect
for visibility, this is the error message one would get:
Copy code
MappingError: Failed to parse ./cheeseshop/repository/BUILD:
BuildFileVisibilityRulesError: Invalid rule spec, Target spec must not be empty. {}
c
The docs should then be updated to reflect what is working. Thanks!
f
definitely! I would want Andreas to confirm this first.
c
“TypeError: decoding to str: need a bytes-like object, Registrar found”,
that is a bug, thanks for reporting. I recall this having been reported once before but no issue was submitted so it’s been overlooked. https://github.com/pantsbuild/pants/issues/19390
# We need another rule set, in case we have non-python sources in here, to avoid fall-through.
# Sticking in a generic catch-all allow-all rule.
({}, "*"),
This is wrong, sorry about that. We really should have doc-tests 😅 The selector
{}
doesn’t match anything, so will not apply to anything so the rules that follow (the
"*"
in this case) won’t ever be used, hence the error message. https://github.com/pantsbuild/pants/issues/19391
🙏🏽 1