Commit Graph

1861 Commits

Author SHA1 Message Date
Jelle Zijlstra
3702ba224e
Prepare release 24.4.2 (#4335)
* Prepare release 24.4.2

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-25 16:52:26 -07:00
Jelle Zijlstra
e4aaa8a994
Fix incorrect f-string tokenization (#4332) 2024-04-25 16:45:46 -07:00
Jelle Zijlstra
ba88fc372e
Simplify string tokenization regexes (#4331) 2024-04-24 23:11:31 -07:00
Jelle Zijlstra
5683242fd4 New release template 2024-04-24 20:22:56 -07:00
Jelle Zijlstra
e7fb048281
Prepare release 24.4.1 (#4328) 2024-04-24 07:23:25 -07:00
Jelle Zijlstra
3f0f8f1956
Support PEP 696 (#4327) 2024-04-23 22:08:37 -07:00
S.S
2f88085da5
Github Action: Directly install from repo if export-subst is skipped (#4313) 2024-04-23 20:01:53 -07:00
Shantanu
12ce3db077
Move changelog entry to right section (#4326)
Crashes are usually documented in the stable style portion of the
changelog. This patch doesn't affect the parser (e.g. blib2to3).
Noticed the second after I merged :-)
2024-04-23 19:26:49 -07:00
peterkra25
1354be2525
Add support to style function definitions with newlines before function stubs (#4318)
* Add support to style function definitions containing newlines before function stubs

* Relocated implementation for removal of newlines before function stubs with added tests for comments

---------

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-04-23 19:19:56 -07:00
Tushar Sadhwani
f4b644b82f
Prevent wrapping of multiline fstrings in parens (#4325) 2024-04-23 14:16:47 -07:00
Tushar Sadhwani
551ede2825
Add PEP 701 support (#3822)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-04-22 08:19:19 -07:00
dependabot[bot]
944b99aa91
Bump sphinx from 7.2.6 to 7.3.7 in /docs (#4322)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 7.2.6 to 7.3.7.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.rst)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.2.6...v7.3.7)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-22 00:01:38 -07:00
Shantanu
7134754ef4
Remove node-specific logic from visit_default (#4321)
This is the point of a visitor
2024-04-21 23:59:29 -07:00
Shantanu
7669381420
Pin to old flake8-bugbear (#4319)
See https://github.com/PyCQA/flake8-bugbear/issues/467 or https://github.com/psf/black/pull/4318
2024-04-21 20:19:47 -07:00
Shantanu
735733b205
Use uv in docs build (#4310)
Currently pip spends about 20s
2024-04-14 01:51:07 -07:00
Harsha S
9dc9114aef
Mention pipx installation 2024-04-14 01:11:24 -07:00
Shantanu
66e2b11571
Add new change template (#4308) 2024-04-12 13:25:36 -07:00
Shantanu
8fe627072f
Prepare release 24.4.0 (#4307) 2024-04-12 13:12:22 -07:00
dependabot[bot]
6b25e7cdab
Bump peter-evans/find-comment from 3.0.0 to 3.1.0 (#4304)
Bumps [peter-evans/find-comment](https://github.com/peter-evans/find-comment) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/peter-evans/find-comment/releases)
- [Commits](d5fe37641a...3eae4d3798)

---
updated-dependencies:
- dependency-name: peter-evans/find-comment
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-08 09:40:15 -04:00
alwayshang
07fe1ca88a
docs: remove repetitive word (#4303)
Signed-off-by: alwayshang <zhanghonghao@outlook.com>
2024-04-07 00:18:00 -07:00
Sebastian Rittau
3383f531bc
GitHub Action: Allow reading version from pyproject.toml (#4294)
Closes #4285

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-04-05 08:40:40 -04:00
pre-commit-ci[bot]
c8f1a5542c
[pre-commit.ci] pre-commit autoupdate (#4297) 2024-04-01 15:51:24 -07:00
Shantanu
836acad863
Improve AST safety check (#4290)
Fixes #4288, regressed by #4270
2024-03-22 20:13:53 -06:00
cobalt
13bd0925eb
fix: Stop moving multiline strings to a new line unless inside brackets (#4289)
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-03-22 20:11:01 -06:00
Shantanu
c9d2635b55
Remove mocking from tests (#4287)
Fixes #4275
2024-03-20 18:15:42 -07:00
Yilei Yang
bf1195612c
Fix two logging calls in the test helper (#4286)
They were missing formatting interpolation operators.
2024-03-19 22:04:48 -07:00
dependabot[bot]
97993f997f
Bump pypa/cibuildwheel from 2.16.5 to 2.17.0 (#4283)
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.16.5 to 2.17.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.16.5...v2.17.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-18 12:19:55 -06:00
rdrll
f78b15712a
Fix formatting for if clauses in match-case blocks (#4269)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-03-16 07:38:07 -07:00
Jelle Zijlstra
8332a75e82 Add new change template 2024-03-15 12:40:29 -07:00
Jelle Zijlstra
552baf8229
Prepare release 24.3.0 (#4279) 2024-03-15 12:17:00 -07:00
Jelle Zijlstra
f000936726
Fix catastrophic performance in lines_with_leading_tabs_expanded() (#4278) 2024-03-15 12:06:12 -07:00
Samson Umezulike
7b5a657285
Fix --line-ranges behavior when ranges are at EOF (#4273)
Fixes #4264
2024-03-15 11:18:47 -07:00
Kai Sforza
1abcffc818
Use regex where we ignore case on windows (#4252)
On windows the path `FoObAR` is the same as `foobar`, so the output
of `black` on a windows machine could output the path to `.gitignore`
with an upper or lower-case drive letter.
2024-03-12 21:22:10 -07:00
Daniel Krzeminski
719e67462c
Fix 4227: Improve documentation for --quiet --check (#4236)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-03-12 21:15:29 -07:00
Charpy
e5510afc06
update plugin url for Thonny (#4259) 2024-03-12 21:14:06 -07:00
Jelle Zijlstra
6af7d11096
Fix AST safety check false negative (#4270)
Fixes #4268

Previously we would allow whitespace changes in all strings, now
only in docstrings.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-03-09 17:42:29 -08:00
Zac Hatfield-Dodds
f03ee113c9
Ensure blib2to3.pygram is initialized before use (#4224) 2024-03-02 19:31:02 -08:00
cobalt
e4bfedbec2
fix: Don't move comments while splitting delimiters (#4248)
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-03-01 07:02:56 -08:00
cobalt
d0287e1f75
Make trailing comma logic more concise (#4202)
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-02-28 13:20:46 -08:00
cobalt
0f18001abf
chore: Refactor delimiter_split() (#4257)
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-02-28 08:27:57 -08:00
Victorien
899002399a
Remove usage of pkg_resources in docs/conf.py (#4251) 2024-02-26 07:49:39 -08:00
Shantanu
ea66d40dd7
Update empty line documentation (#4239)
Reflects status quo following #4043

Fixes #4238
2024-02-25 16:36:52 -08:00
Shantanu
d1d4fc58d3
Add new release template (#4228) 2024-02-12 12:46:16 -08:00
Shantanu
6fdf8a4af2
Prepare release 24.2.0 (#4226) 2024-02-12 12:11:15 -08:00
cobalt
8af439407c
fix: Don't remove comments along with parens (#4218)
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
2024-02-12 06:27:50 -08:00
dependabot[bot]
35e9776919
Bump pre-commit/action from 3.0.0 to 3.0.1 (#4225)
Bumps [pre-commit/action](https://github.com/pre-commit/action) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/pre-commit/action/releases)
- [Commits](https://github.com/pre-commit/action/compare/v3.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: pre-commit/action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 06:19:25 -08:00
Shantanu
23dfc5b2c3
Fix ignoring input files for symlink reasons (#4222)
This relates to #4015, #4161 and the behaviour of os.getcwd()

Black is a big user of pathlib and as such loves doing `.resolve()`,
since for a long time it was the only good way of getting an absolute
path in pathlib. However, this has two problems:

The first minor problem is performance, e.g. in #3751 I (safely) got rid
of a bunch of `.resolve()` which made Black 40% faster on cached runs.

The second more important problem is that always resolving symlinks
results in unintuitive exclusion behaviour. For instance, a gitignored
symlink should never alter formatting of your actual code. This kind of
thing was reported by users a few times.

In #3846, I improved the exclusion rule logic for symlinks in
`gen_python_files` and everything was good.

But `gen_python_files` isn't enough, there's also `get_sources`, which
handles user specified paths directly (instead of files Black
discovers). So in #4015, I made a very similar change to #3846 for
`get_sources`, and this is where some problems began.

The core issue was the line:
```
root_relative_path = path.absolute().relative_to(root).as_posix()
```
The first issue is that despite root being computed from user inputs, we
call `.resolve()` while computing it (likely unecessarily). Which means
that `path` may not actually be relative to `root`. So I started off
this PR trying to fix that, when I ran into the second issue. Which is
that `os.getcwd()` (as called by `os.path.abspath` or `Path.absolute` or
`Path.cwd`) also often resolves symlinks!
```
>>> import os
>>> os.environ.get("PWD")
'/Users/shantanu/dev/black/symlink/bug'
>>> os.getcwd()
'/Users/shantanu/dev/black/actual/bug'
```
This also meant that the breakage often would not show up when input
relative paths.

This doesn't affect `gen_python_files` / #3846 because things are always
absolute and known to be relative to `root`.

Anyway, it looks like #4161 fixed the crash by just swallowing the error
and ignoring the file. Instead, we should just try to compute the actual
relative path. I think this PR should be quite safe, but we could also
consider reverting some of the previous changes; the associated issues
weren't too popular.

At the same time, I think there's still behaviour that can be improved
and I kind of want to make larger changes, but maybe I'll save that for
if we do something like #3952

Hopefully fixes #4205, fixes #4209, actual fix for #4077
2024-02-12 00:04:09 -08:00
Shantanu
a20100395c
Simplify check for symlinks that resolve outside root (#4221)
This PR does not change any behaviour.

There have been 1-2 issues about symlinks recently. Both over and under
resolving can cause problems. This makes a case where we resolve more
explicit and prevent a resolved path from leaking out via the return.
2024-02-10 23:55:01 -08:00
Logan Hunt
dab37a6a11
Remove redundant parentheses in case statement if guards (#4214)
A follow up to #4024 but for `if` guards in `case` statements. I noticed this
when #4024 was made stable, and noticed I had some code that had extra parens
around the `if` guard.
2024-02-07 06:55:02 -08:00
Seung Wan Yoo
32230e6f5c
fix: bug where the doublestar operation had inconsistent formatting. (#4154)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-02-05 05:33:11 -08:00