Another bike shed! A flagship feature for Pants 2....
# general
h
Another bike shed! A flagship feature for Pants 2.8 is the
overrides
field, which allows you to more easily override metadata for a single file w/o having to define new targets. For example,
Copy code
overrides={
  "foo_test.py": {"timeout": 120},
  ("bar_test.py", "baz_test.py"): {"timeout": 240},
}
Feedback welcomed on what this syntax should look like: ๐Ÿงต
Do we go with that nested dictionary syntax, or something like this?
Copy code
overrides={
  "foo_test.py": override(timeout=120),
  ("bar_test.py", "baz_test.py"): override(timeout= 240),
}
p
What benefit does
override()
provide over the dict syntax?
h
Zero change in functionality, only a question of what color you prefer to paint the bikeshed. The argument for it is alignment with target syntax of
kwarg="value"
my fear is
overrides
is already hard to type -- I confuse myself with the number of `r`s to put. (Speaking of which, totally open to better names for that field!)
p
If someone doesn't like the
{"timeout": 240}
dict literal, they can always use
dict(timeout=240)
. So, I think
override()
is a step too far.
๐Ÿ‘ 1
๐Ÿ’ฏ 1
h
Oh that's a great point!
So then next question, any opinion on what our docs should use?
dict()
or
{}
? I'm trying to keep in mind what non-Python developers might prefer, but that's hard because of the Curse of Knowledge ๐Ÿค”
p
dict literals - each exposure to python and python dialects should nudge people toward good practice.
dict()
is generally bad practice imo.
๐Ÿ‘ 1
h
John Sirois sometimes counter-argues that a benefit of
dict()
it forces the keys to already be
str
, which is important here. But not sure that's worth it
I think a reason to prefer literals is consistency. You avoid any confusion for non-Python developers wondering "what is
dict(timeout=120)
, and is it any different than
{}
?"
p
Yeah I don't buy that (about
dict()
helping to enforce string keys). You can validate and throw an error on non string keys, and then you can print a more helpful message than a python syntax error.
โž• 1
๐Ÿ‘ 1