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

Support formatting specified lines. #4020

Merged
merged 13 commits into from Nov 7, 2023
Merged

Support formatting specified lines. #4020

merged 13 commits into from Nov 7, 2023

Conversation

yilei
Copy link
Contributor

@yilei yilei commented Nov 3, 2023

Description

This adds a command-line option --line-ranges=, to tell Black to only format these specified lines.

Fixes #830

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Copy link

github-actions bot commented Nov 3, 2023

diff-shades reports zero changes comparing this PR (bd6d7ff) to main (ecbd9e8).


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

Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good, just a few pieces of minor feedback.

This has been a long-standing feature request, so it's great to finally see it in Black.

docs/usage_and_configuration/the_basics.md Outdated Show resolved Hide resolved
src/black/ranges.py Outdated Show resolved Hide resolved
src/black/ranges.py Outdated Show resolved Hide resolved
src/black/ranges.py Outdated Show resolved Hide resolved
tests/test_ranges.py Outdated Show resolved Hide resolved
yilei and others added 6 commits November 6, 2023 17:35
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@yilei
Copy link
Contributor Author

yilei commented Nov 7, 2023

Thanks for the review! Updated.

@JelleZijlstra JelleZijlstra merged commit 46be1f8 into psf:main Nov 7, 2023
41 checks passed
@yilei yilei deleted the ranges branch November 7, 2023 02:52
@fearedbliss
Copy link

Thanks for implementing this @yilei. This will be extremely useful in many situations and circumstances.

@henriholopainen
Copy link
Contributor

Funnily enough, I was working on the same feature and only now realised it had been finished when trying to open a draft PR. 😛 Oh well, what it's worth, my approach can be found here.

@henriholopainen
Copy link
Contributor

Also this PR might be enough to close this issue

@yilei
Copy link
Contributor Author

yilei commented Nov 8, 2023

@henriholopainen Ah I'm sorry I didn't realize you were working on it. I should have sent the PR earlier as I've had it implemented for a while now.

@tartley
Copy link

tartley commented Nov 8, 2023

This option doesn't appear to be working right for me. I'll post a minimal issue...

@tartley
Copy link

tartley commented Nov 8, 2023

Minimal repro posted here: #4033

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.

[Feature Request] Allow command line option to only reformat specific lines
5 participants