-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
Use pants.toml
internally
#9090
Conversation
df446ce
to
d0433e1
Compare
pants.toml
internallypants.toml
internally
d2c1370
to
fc9003c
Compare
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.
Reviewers: each commit is distinct and they're generally ordered logically (although it looks like GitHub swapped the order of the last two commits?)
@@ -83,7 +83,7 @@ def generate_new_config(config: Path) -> List[str]: | |||
for i, line in enumerate(original_text_lines): | |||
option_regex = r"(?P<option>[a-zA-Z0-9_]+)" | |||
before_value_regex = rf"\s*{option_regex}\s*[:=]\s*" | |||
valid_value_characters = r"a-zA-Z0-9_.@!%\=\>\<\-\(\)\/" | |||
valid_value_characters = r"a-zA-Z0-9_.@!:%\=\>\<\-\(\)\/" |
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.
Without this, we weren't properly converting options with :
in the value, such as target: src/python:example
.
# --remote-oauth-bearer-token-path=<(gcloud auth application-default print-access-token | perl -p -e 'chomp if eof') | ||
# --no-v1 --v2 test tests/python/pants_test/util:strutil | ||
# | ||
# Remoting does not work for every goal, so you should not permanently point to this ini file, e.g. | ||
# via an env var; only point to it when you want to remote a specific invocation. | ||
|
||
[DEFAULT] |
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.
I changed this to GLOBAL
. It works to be DEFAULT
but is not very idiomatic. DEFAULT
is useful when you want to use string interpolation or apply an option to multiple sections.
if option in self.defaults: | ||
return self._stringify_val(self.defaults[option]) | ||
if option not in section_values: | ||
raise configparser.NoOptionError(option, section) | ||
if option not in self.defaults: | ||
raise configparser.NoOptionError(option, section) | ||
return self._stringify_val(self.defaults[option]) |
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.
These changes were necessary to get it working when an option overrides a DEFAULT option with the same name.
|
||
|
||
@dataclass(frozen=True) | ||
class TomlSerializer: |
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.
Currently, we only use this for PantsRunIntegrationTest
, but I imagine we might have some use down the road so I put it in config.py
.
# Conflicts: # pants.ini
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.
✔️
I'm not sure this description covers the change to also using e.g. |
I was planning in a followup to propose deprecating INI so that we can consolidate around one sane config file. I first mentioned my intention to propose doing this in the original TOML PR: #9052. It's also why it was so important to me that we have Good point about not updating any public-facing deprecation warnings, though! You're right that it doesn't belong here and I was being lazy including here. |
….toml. Stick with pants.ini We do still update all tests to refer to TOML, though, as this PR makes that change.
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.
Awesome!
I had canceled the CI run on this last commit because it only made 3 small changes to docstring / user-messages. The prior commit was green. Thanks for the reviews! |
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.
Thanks!
"%(buildroot)s/contrib/thrifty/src/python", | ||
"%(buildroot)s/pants-plugins/src/python", | ||
] | ||
backend_packages.add = [ |
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.
Can toml
keys contain any useful special characters? If so, it might actually be desirable to have the ".add"/".remove" syntaxes jump out even more than they do as magical... strawman:
backend_packages.++ = [
..
]
(related: @illicitonion recently pointed out a convention of using #
keys in json to add comments, which made me think about 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.
Oh good idea! Unfortunately, with the current spec, you'd have to wrap it in quotes:
backend_packages."++" = [
"..",
]
But they're considering loosening the spec to allow any unicode symbol for a key name (particularly helpful for other languages). toml-lang/toml#687
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.
I didn't submit the review the first time :(
"\n\nTo prepare, set `skip: True` in your `pants.ini` under the section " | ||
"`python-eval`. If you still need to use this tool, set `skip: False`. In " | ||
"Pants 1.27.0.dev0, the default will change from `skip: False` to `skip: True`, " | ||
"\n\nTo prepare, set `skip = true` in your `pants.toml` under the section " |
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.
I'm sure there's cases of this old ini
syntax still hanging around in the codebase, even if the comments don't specifically refer to pants.ini
. It's probably out of the scope of this change, but would it make sense to open a follow-up issue to search and change those?
This allows us to dogfood TOML support.
We make several changes to land this:
migrate_to_toml_config.py
to work with:
, e.g.src/python:target
.config.TomlSerializer
to convert a parsed Python dictionary of option-scopes -> options into a TOML representation.We do not change any public-facing documentation or user-messages - those still refer to INI.