Skip to content

Split preview into --preview and --unstable? #4093

@JelleZijlstra

Description

@JelleZijlstra

Black's --preview mode is supposed to give a preview of what next year's stable style will look like. But for the last few years, it hasn't been able to do that job, because --preview includes experimental string processing, which produces numerous bugs and likely again won't make it into the 2024 stable style (#4042). Several other current preview features likely won't make it into the 2024 stable style.

I propose to add a new style, --unstable. The idea would be that --preview is only for new style features that we currently think would make it into next year's stable style, and --unstable is for new features that we would like to eventually stabilize, but that are currently still buggy. --unstable would include all --preview features. This way, --preview will truly be a preview.

Concrete rules:

  • Any preview feature that leads to new crashes (e.g., stability bugs) should be demoted to --unstable until the issue is fixed.
  • Similarly, if a preview feature is shown to lead to bad formatting in some cases (in our judgment as maintainers), we demote the feature to unstable. For example, Black unexpectedly alters comments and one-liner expressions when comments are placed above, when using --preview #3555 should make us demote the related preview feature to unstable.
  • New preview features merged in November or December would by default go into --unstable, so that there is enough time for the ecosystem to try out the new feature. We can make exceptions for sufficiently simple and uncontroversial changes. We'd move these features into --preview once the new year starts.

Alternative solutions considered:

  • We could simply be more aggressive in deleting preview features that cause trouble. I'd personally be hesitant to do this though, especially for features that have had significant effort invested into them: it will be a lot more effort to apply them to the Black codebase again later once the original issue is fixed. However, I do think we should delete unstable features that have remained in that state for too long.
  • We could move unstable features out of --preview, but not add a separate --unstable flag. Instead, we could add a private flag like -X string_processing to enable individual preview features. This would allow more targeted testing, but it opens the door to more configurability than I'd like, and might lead to users expecting us to continue supporting such fine-grained configuration control.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions