Skip to content

Deprecate unusual ways to set things in pyproject.toml #4178

@JelleZijlstra

Description

@JelleZijlstra

@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_length and line-length. In Henry's sample, line_length was used about 3% as much as line-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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions