Commit Graph

1724 Commits

Author SHA1 Message Date
Shantanu
2e4fac9d87
Apply force exclude logic before symlink resolution (#4015) 2023-11-07 11:31:44 -08:00
Henri Holopainen
66008fda5d
[563] Fix standalone comments inside complex blocks crashing Black (#4016)
Bracket depth is not an accurate indicator of standalone comment position inside more complex blocks because bracket depth can be virtual (in loops' and lambdas' parameter blocks) or from optional parens. Here we try to stop cumulating lines upon standalone comments in complex blocks, and try to make standalone comment processing more simple. The fundamental idea is, that if we have a standalone comment, it needs to go on its own line, so we always have to split.

This is not perfect, but at least a first step.
2023-11-07 11:29:24 -08:00
rdrll
50ed6221d9
Fix long case blocks not split into multiple lines (#4024)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-07 06:31:58 -08:00
Yilei Yang
46be1f8e54
Support formatting specified lines (#4020) 2023-11-06 18:05:25 -08:00
Shantanu
ecbd9e8cf7
Fix crash with f-string docstrings (#4019)
Python does not consider f-strings to be docstrings, so we probably
shouldn't be formatting them as such

Fixes #4018

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-06 16:58:43 -08:00
Yilei Yang
e808e61db8
Preview: Keep requiring two empty lines between module-level docstring and first function or class definition (#4028)
Fixes #4027.
2023-11-06 14:30:04 -08:00
Shantanu
9e3daa1107
Fix arm wheels on macOS (#4017) 2023-11-05 18:29:37 -08:00
Ran Benita
448324637d
Enable branch coverage (#4022)
When trying to understand the code logic, and looking at coverage
reports, branch coverage is very helpful.
2023-11-04 13:49:12 -07:00
Jelle Zijlstra
c54c213d6a
Fix crash on await (a ** b) (#3994) 2023-11-02 20:42:11 -07:00
Shantanu
e2f2bd076f
Minor refactoring in get_sources and gen_python_files (#4013) 2023-11-01 06:20:14 -07:00
Jelle Zijlstra
5758da6e3c
Fix bytes strings being treated as docstrings (#4003)
Fixes #4002
2023-10-31 17:11:28 -07:00
Henri Holopainen
e50110353a
Produce equivalent code for docstrings containing backslash followed by whitespace(s) before newline (#4008)
Fixes #3727
2023-10-31 08:27:11 -07:00
Henri Holopainen
ddfecf06c1
Hug parens also with multiline unpacking (#3992) 2023-10-30 08:35:26 -07:00
Cooper Lees
f7cbe4ae1b
Add release tool (#3974)
* Add release tool

- Add tool for release managers to use to generate commits
  - I'm trying to only use stdlib so we have no depdencies ...
- Default is to change date strings in hard coded documentation files + CHANGES.md
  - I write directly to files cause we have SCM to fix any screw ups ...
- We hackily convert calver to ints to sort (all for better ideas here)
  - If we hit a ValueError we just set to 0 for sorting - This is alhpa + beta release we can safely ignore these days
- Add new CI to only run release unittests in 3.12 only on all platforms
- Update release docs

- Checked with `mypy --strict` + ensure we are `black --preview` formatted :D

Tests:
- Run it to generate template PR
  - `python3.12 release.py --debug --add-changes-template`
- Run it to cleanup CHANGE.md + change version in specified doc files
```
crl-m1:black cooper$ python3.12 release.py -d
[2023-10-23 23:39:38,414] INFO: Current version detected to be 23.10.1 (release.py:221)
[2023-10-23 23:39:38,414] INFO: Next version will be 23.10.2 (release.py:222)
[2023-10-23 23:39:38,414] INFO: Cleaning up /Users/cooper/repos/black/CHANGES.md (release.py:127)
[2023-10-23 23:39:38,416] DEBUG: Finished Cleaning up /Users/cooper/repos/black/CHANGES.md (release.py:147)
[2023-10-23 23:39:38,416] INFO: Updating black version to 23.10.2 in /Users/cooper/repos/black/docs/integrations/source_version_control.md (release.py:173)
[2023-10-23 23:39:38,416] DEBUG: Finished updating black version to 23.10.2 in /Users/cooper/repos/black/docs/integrations/source_version_control.md (release.py:185)
[2023-10-23 23:39:38,416] INFO: Updating black version to 23.10.2 in /Users/cooper/repos/black/docs/usage_and_configuration/the_basics.md (release.py:173)
[2023-10-23 23:39:38,417] DEBUG: Finished updating black version to 23.10.2 in /Users/cooper/repos/black/docs/usage_and_configuration/the_basics.md (release.py:185)
```
- Add tests around some key logic

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

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

* Fix lints + add git to release CI

- Remove black + mypy as linting already runs it ...
- Ignore delete param to TemporaryDirectory as we can't set mypy to 3.12 :D

* Only run CI on linux/ubuntu for now

* Add lots of debug printing + directly run unitests (not via coverage)

* Overloading __str__ is bad on a TestCase

* Add more logging around git tag

* Print where git is in a step

* Rollback creating a fake black repo as we were not using it - I did plan to but I can't get it working on GitHub actions

* Do a deep checkout

* Add noqa for E701,E761 ... maybe we need this in our flake8 config now?

* Fix action to have correct workflow yaml to action on
- Also add fix to not double run when we push directly to psf/black

* All jelle suggestions
- Fix bug missing lines ending with --> in CHANGES.md to delete ...
- Update ci to run out of scripts dir too
- Update test_tuple_calver

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-29 15:34:38 -07:00
Aditya Garg
5515a5ac7a
Update README.md (#3997)
Fixed a grammatical error in README.md
2023-10-29 10:28:33 -07:00
Jelle Zijlstra
5edd99312a
Regression test for match variable inside match (#3993) 2023-10-28 11:05:53 -07:00
Shivam Singh
9a90fa2cb7
Fix typo in README.md (#3995) 2023-10-28 10:48:18 -07:00
David Culley
7686989fc8
confine pre-commit to stages (#3940)
See https://pre-commit.com/#confining-hooks-to-run-at-certain-stages

> If you are authoring a tool, it is usually a good idea to provide an appropriate `stages` property. For example a reasonable setting for a linter or code formatter would be `stages: [pre-commit, pre-merge-commit, pre-push, manual]`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-27 15:43:34 -07:00
Satyam Namdev
53c4278a4c
Update CHANGES.md (#3988)
Fixed a grammatical mistake
2023-10-27 13:27:19 -07:00
Shantanu
c712d57ca9
Add trailing comma test case for hugging parens (#3991) 2023-10-27 12:17:54 -07:00
Gabriel Perren
caef19689b
Update current_style.md (#3990)
Fix small typo
2023-10-27 11:54:31 -07:00
sth
c369e446f9
Fix matching of absolute paths in --include (#3976) 2023-10-27 00:43:51 -07:00
Surav Shrestha
7bfa35cca8
docs: fix typos in change log and documentations (#3985) 2023-10-26 21:26:47 -07:00
Shantanu
de701fe6aa
Fix CI by running on Python 3.11 (#3984)
aiohttp doesn't yet support 3.12
2023-10-26 21:13:25 -07:00
Ikko Eltociear Ashimine
f7174bfc43
Fix typo in future_style.md (#3979)
parantheses -> parentheses
2023-10-26 09:43:42 -07:00
Henri Holopainen
878937bcc3
[2213] Add support for single line format skip with other comments on the same line (#3959) 2023-10-25 09:47:21 -07:00
Henri Holopainen
1d4c31aa58
[925] Improve multiline dictionary and list indentation for sole function parameter (#3964) 2023-10-25 08:35:37 -07:00
Cooper Lees
ef1048d5f8
Add Unreleased template to CHANGES.md (#3973)
Add Unreleased template to CHANGES.md - Did this via tool working on in another branch
2023-10-24 01:26:40 -05:00
Cooper Lees
744d23b348
Prepare release 23.10.1 (#3969)
* Prepare release 23.10.1

* Update docs/usage_and_configuration/the_basics.md

Add missed version string

We need to automate or remove this from docs ... It's painful.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

---------

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-23 10:59:16 -07:00
Kiyoon Kim
8de4be5168
Fix CI failing (#3957)
* Fix CI failing

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

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

* docs: update CHANGES.md

* docs: fix changelog location to unreleased

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-23 10:37:14 -07:00
William Moreno
c0adca321d
docs: specifies the use of the .git-blame-ignore-revs file (#3961) 2023-10-23 10:21:58 -07:00
Dario Curreri
a7643fac8d
Add summary parameter to action (#3958) 2023-10-23 09:40:09 -07:00
Cooper Lees
d291c2338c
Move Docker image to hatch + compile (#3965) 2023-10-23 08:36:47 -07:00
dependabot[bot]
7f1c578b89
Bump peter-evans/create-or-update-comment from 3.0.2 to 3.1.0 (#3966)
Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 3.0.2 to 3.1.0.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](c6c9a1a660...23ff15729e)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-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>
2023-10-23 07:42:49 -07:00
Henri Holopainen
2db5ab0a7b
Allow empty line after block open before a comment or compound statement (#3967) 2023-10-23 07:38:36 -07:00
Aniket Patil
0a37888e79
Fix typos in CHANGES.md (#3963) 2023-10-22 14:16:43 -07:00
Henri Holopainen
882d8795c6
Fix merging implicit multiline strings that have inline comments (#3956)
* Fix test behaviour

* Add new test cases

* Skip merging strings that have inline comments

* Don't merge lines with multiline strings with inline comments

* Changelog entry

* Document implicit multiline string merging rules

* Fix PR number
2023-10-19 20:09:33 -07:00
Jelle Zijlstra
9edba85f71
Prepare release 23.10.0 (#3951) 2023-10-17 07:22:24 -07:00
Jelle Zijlstra
bb588073ab
Fix parser bug where "type" was misinterpreted as a keyword inside a match (#3950)
Fixes #3790

Slightly hacky, but I think this is correct and it should also improve performance somewhat.
2023-10-17 00:59:15 -07:00
Jelle Zijlstra
722735d20e
Fix grammar for type alias support (#3949)
Fixes #3948
2023-10-16 10:53:38 -07:00
Jelle Zijlstra
abe57e3d92
Treat raw strings like other docstrings (#3947)
Fixes #3944
2023-10-16 10:51:51 -07:00
Henri Holopainen
1648ac5180
Fix long lines with power operator(s) getting splitted before line length (#3942)
Fixes #3889
2023-10-16 07:08:21 -07:00
Charles Patel
6f84f65285
Migrate mypy config to pyproject.toml (#3936)
Co-authored-by: Charles Patel <charles.patel@apkudo.com>
2023-10-16 05:24:16 -07:00
rdrll
3bb92146f5
CI Test: Deprecating 'Healthcheck.all()' from Hypothesis in fuzz.py (#3945) 2023-10-16 05:13:53 -07:00
Jelle Zijlstra
935f303a0a
Fix test that was not being run (#3939) 2023-10-09 20:02:27 -07:00
Daniël van Noord
b7717c3f1e
Standardise newlines after module-level docstrings (#3932)
Co-authored-by: jpy-git <josephyoung.jpy@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-09 19:34:26 -07:00
Shantanu
7aa37ea0ad
Report all stacktraces in verbose mode (#3938)
Previously these were swallowed (unlike the ones in black/__init__.py)
2023-10-09 19:15:51 -07:00
Shantanu
5d5bf6e087
Fix cache versioning when BLACK_CACHE_DIR is set (#3937) 2023-10-09 18:44:36 -07:00
Jelle Zijlstra
a69bda3b9b
Use inline flags for test cases (#3931)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-10-09 18:43:47 -07:00
Shantanu
715f60c11b
Drop support for parsing Python 2 (#3933) 2023-10-09 07:02:49 -07:00