Skip to content
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

Add --unstable flag #4096

Merged
merged 53 commits into from Jan 26, 2024
Merged

Add --unstable flag #4096

merged 53 commits into from Jan 26, 2024

Conversation

JelleZijlstra
Copy link
Collaborator

Closes #4093.

We'd need more discussion before we actually implement that idea, but this also allows me to test whether string processing is responsible for diff-shades crashing all the time.

@JelleZijlstra
Copy link
Collaborator Author

but this also allows me to test whether string processing is responsible for diff-shades crashing all the time.

Seems like that's not it.

Copy link

github-actions bot commented Dec 10, 2023

diff-shades results comparing this PR (718ce47) to main (8fe602b). The full diff is available in the logs under the "Generate HTML diff report" step.

╭────────────────────────────── Summary ──────────────────────────────╮
│ 19 projects & 1148 files changed / 30 347 changes [+16 746/-13 601] │
│                                                                     │
│ ... out of 2 550 899 lines, 12 217 files & 23 projects              │
╰─────────────────────────────────────────────────────────────────────╯

Differences found.

What is this? | Workflow run | diff-shades documentation

@JelleZijlstra
Copy link
Collaborator Author

Merged the stable style branch (#4106) into this one, and added documentation. I think we should merge this in time for 24.1.0.

@@ -449,6 +449,12 @@ file that are not enforced yet but might be in a future version of the formatter
_Black_ will normalize line endings (`\n` or `\r\n`) based on the first line ending of
the file.

### Form feed characters
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from "future style", this change is in the 2024 stable style

@@ -1,117 +1,38 @@
# The (future of the) Black code style

```{warning}
Changes to this document often aren't tied and don't relate to releases of
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning isn't really true any more now that we explicitly list preview features.

_Black_. It's recommended that you read the latest version available.
```

## Using backslashes for with statements
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to the end as it's a speculative feature that we haven't even implemented. The real-world preview style is more important.

src/black/mode.py Outdated Show resolved Hide resolved
@JelleZijlstra
Copy link
Collaborator Author

@hauntsaninja I added a separate --enable-unstable-feature flag as you suggested (you called it --enable-unstable-hidden-feature but that felt redundant).

I took the opportunity to remove --experimental-string-processing; it's been deprecated for two years and now you can use --preview --enable-feature string_processing instead.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this happen!

CHANGES.md Outdated
@@ -53,6 +61,7 @@ release:

<!-- Changes that affect Black's preview style -->

- Add `--unstable` style (#4096)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a quick link / blurb here for preview style codebases that want hug_parens?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the hugging feature (hug_parens_with_braces_and_square_brackets) in preview. Or maybe you're referring to multiline_string_handling?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also possibly hug_parens_with_braces_and_square_brackets should go into unstable; I haven't thought much about it beyond not putting it in 2024 stable. We have 11 months left to do that though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, I was wrong on the specifics. Just thought more of a mention in changelog could be nice for whatever unstable features users may want

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll add something.

)
@click.option(
"--enable-unstable-feature",
type=click.Choice([v.name for v in UNSTABLE_FEATURES]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be worth it to be more permissive here, so folks can set --enable-unstable-feature hug_parens and forget about it for a year. But I think that much bother is probably fine for preview...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's actually fine since we only allow --enable-unstable-feature if you also have --preview, so setting it for a flag that's in preview is a no-op. I'll change this.

@JelleZijlstra JelleZijlstra merged commit 4f47cac into psf:main Jan 26, 2024
45 of 46 checks passed
@JelleZijlstra JelleZijlstra deleted the unstable branch January 26, 2024 01:00
RedGuy12 pushed a commit to RedGuy12/black that referenced this pull request Jan 26, 2024
JelleZijlstra added a commit to JelleZijlstra/black that referenced this pull request Jan 28, 2024
In psf#4096 I added a list of current preview/unstable features to the docs. I think
this is important for publicizing what's in our preview style. This PR adds an
automated test to ensure the list stays up to date in the future.
hauntsaninja pushed a commit that referenced this pull request Jan 31, 2024
In #4096 I added a list of current preview/unstable features to the docs. I think
this is important for publicizing what's in our preview style. This PR adds an
automated test to ensure the list stays up to date in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split preview into --preview and --unstable?
4 participants