Deprecate unusual ways to set things in pyproject.toml
@henryiii shared some useful data on common Black configurations in pyproject.toml files found on PyPI. A few pieces of weirdness stood out:
- Some people set line-length to a string, e.g.
line-length = "100". This is very rare, about 25 instances total out of almost 20k (~0.1%). - We allow both
line_lengthandline-length. In Henry's sample,line_lengthwas used about 3% as much asline-length. Our documentation only uses the hyphenated versions.
This might cause problems when we add a JSON schema (#4160), because it's harder to provide useful feedback to users if anything is allowed. For the typing issue, it also just seems confusing to allow setting an integer value to a string.
Proposed actions:
- In the documentation, state clearly that the hyphenated versions are preferred and that you should use the right type.
- Print a warning if we encounter the incorrect versions, and possibly remove support for them in Black 25 next year. I feel this is definitely appropriate for values of the wrong type. For the underscored versions, I feel deprecation is less justifiable as they're more common in practice and less likely to lead to confusion. Curious to hear other opinions on whether that is worth deprecating.
IMO, you could deprecate the unusual types, and produce a warning, and "verbally" deprecate (as in, no warning, but docs discourage it). I think that would be enough to leave the alternate forms out of the Schema, or at the very least have them deprecated there (though most tools don't do much with the info, since it's technically not part of schema v7). Then if usage of the _ versions decreases, maybe eventually a warning could be produced.
Just a thought.
FYI, SchemaStore used to encourage strictness, but has gone toward encouraging matching what tools accept. See https://github.com/SchemaStore/schemastore/issues/3467#issuecomment-1866413005.