Commit Graph

74 Commits

Author SHA1 Message Date
Jelle Zijlstra
8a737e727a
Prepare release 25.1.0 (#4563) 2025-01-28 18:34:41 -08:00
Ac5000
6000d37f09
Add Clarification to Config File Location/Name (#4533) 2024-12-19 16:07:27 -08:00
Jelle Zijlstra
32ebb93003
Clean up Python 3.8 remnants (#4473) 2024-10-08 19:11:22 -07:00
Shantanu
1b2427a2b7
Prepare release 24.10.0 (#4471) 2024-10-07 11:43:01 -07:00
Jelle Zijlstra
b965c2a502
Prepare release 24.8.0 (#4426) 2024-08-02 09:38:22 -07:00
dependabot[bot]
b1f7b9f87d
Bump docker/build-push-action from 5 to 6 (#4387)
* Bump docker/build-push-action from 5 to 6

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

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

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

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-25 08:42:06 -07:00
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
e7fb048281
Prepare release 24.4.1 (#4328) 2024-04-24 07:23:25 -07:00
Shantanu
8fe627072f
Prepare release 24.4.0 (#4307) 2024-04-12 13:12:22 -07:00
Jelle Zijlstra
552baf8229
Prepare release 24.3.0 (#4279) 2024-03-15 12:17:00 -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
Shantanu
6fdf8a4af2
Prepare release 24.2.0 (#4226) 2024-02-12 12:11:15 -08:00
Shantanu
2623269dab
Ignore pyproject.toml missing tool.black section (#4204)
Fixes #2863

This is pretty desirable in a monorepo situation where you have
configuration in the root since it will mean you don't have to
reconfigure every project.

The good news for backward compatibility is that `find_project_root`
continues to stop at any git or hg root, so in all cases repo root
coincides with a pyproject.toml missing tool.black, we'll continue to
have the project root as before and end up using default config
(i.e. we're unlikely to randomly start using the user config).

The other thing we need to be a little careful about is that changing
find_project_root logic affects what `exclude` is relative to.  Since we
only change in cases where there is no config, this only applies where
users were using `exclude` via command line arg (and had pyproject.toml
missing tool.black in a dir that was not repo root).

Finally, for the few who could be affected, the fix is to put an empty
`[tool.black]` in pyproject.toml
2024-02-01 21:50:45 -08:00
Jelle Zijlstra
e026c93888
Prepare release 24.1.1 (#4186) 2024-01-27 20:51:32 -08:00
Jelle Zijlstra
0e6e46b9eb
Prepare release 24.1.0 (#4170) 2024-01-25 20:35:21 -08:00
Jelle Zijlstra
4f47cac192
Add --unstable flag (#4096) 2024-01-25 17:00:47 -08:00
Dragorn421
b7c3a9fedd
Docs: Add note on --exclude about possibly verbose regex (#4145)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-01-11 07:46:17 -08:00
Cooper Lees
ec91a2be3c
Prepare release 23.12.1 (#4124) 2023-12-22 15:04:32 -08:00
Jelle Zijlstra
d9ad09a32b
Prepare release 23.12.0 (#4105) 2023-12-11 21:55:28 -08:00
cobalt
e7e122e9ff
docs: Move fmt: off docs (#4090) 2023-12-09 17:44:15 -08:00
cobalt
432d9050c3
docs: Unify option descriptions between --help and the_basics.md (#4076) 2023-12-07 09:32:06 -08:00
cobalt
50e287cece
docs: Clarify include/exclude documentation (#4072) 2023-12-07 08:38:57 -08:00
Yilei Yang
a8062983cd
Disable the stability check with --line-ranges for now. (#4034)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-11-20 20:45:39 -08:00
cobalt
5773d5cd2b
Document target version inference (#4048) 2023-11-17 13:39:44 -08:00
Jelle Zijlstra
2a1c67e0b2
Prepare release 23.11.0 (#4032) 2023-11-07 20:44:46 -08:00
Yilei Yang
46be1f8e54
Support formatting specified lines (#4020) 2023-11-06 18:05:25 -08: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
Cooper Lees
d291c2338c
Move Docker image to hatch + compile (#3965) 2023-10-23 08:36:47 -07:00
Jelle Zijlstra
9edba85f71
Prepare release 23.10.0 (#3951) 2023-10-17 07:22:24 -07:00
Syed Mohammad Ibrahim
5f6ea5ff20
added the py311 to target-version config (#3898) 2023-09-23 19:23:03 -07:00
Jelle Zijlstra
e87737140f
Prepare release 23.9.1 (#3878) 2023-09-10 17:35:41 -07:00
Jelle Zijlstra
b70b2c6196
Prepare release 23.9.0 (#3863) 2023-09-08 20:24:49 -07:00
Yury V. Zaytsev
d9d0a02d89
Fix typo in target-version param wrongly used in plural (#3817) 2023-07-27 07:12:38 -07:00
Jelle Zijlstra
193ee766ca
Prepare release 23.7.0 (#3776) 2023-07-10 17:09:47 -07:00
Shantanu
7be2735318
Allow specifying --workers via environment variable (#3743) 2023-06-24 16:06:12 -07:00
Ville Skyttä
898915d556
Use aware datetimes to represent UTC (#3728)
Avoids a Python 3.12 deprecation warning.

Subtle difference: previously, timestamps in diff filenames had the
`+0000` separated from the timestamp by space. With this, the space is
there no more, and there is a colon, as in `+00:00`.
2023-06-10 09:54:21 -07:00
Jelle Zijlstra
3decbd6db9
Document each configuration option in more detail (#2839) 2023-05-24 19:55:12 -07:00
Jelle Zijlstra
9b2b048692
Prepare release 23.3.0 (#3625) 2023-03-28 17:46:04 -07:00
Jelle Zijlstra
b0d1fba7ac
Prepare release 23.1.0 (#3536)
Co-authored-by: Richard Si <sichard26@gmail.com>
2023-01-31 18:47:11 -08:00
Bruno Oliveira
4bee9cca55
Remove misleading phrase in Usage and Configuration (#3492)
The CLI options were already shown in the "Command line options" in the same page.
2023-01-11 11:19:27 -08:00
Matthew Armand
3246df89d6
Add latest_prerelease Docker Hub tag for following the latest alpha release (#3465)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-12-20 19:18:15 -08:00
Jelle Zijlstra
2ddea293a8
Prepare release 22.12.0 (#3413) 2022-12-09 07:49:43 -08:00
jlplenio
575220f460
Clarify check argument is needed for github action workflow (#3325)
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-10-15 19:44:02 +01:00
Jelle Zijlstra
27d20144a7
Prepare release 22.10.0 (#3311) 2022-10-06 15:33:51 -07:00
Antonio Ossa-Guerra
4da0851809
Add option to skip the first line of source code (#3299)
* Add option to skip the first line in source file

This commit adds a CLi option to skip the first line in the source
files, just like the Cpython command line allows [1]. By enabling the
flag, using `-x` or `--skip-source-first-line`, the first line is
removed temporarilly while the remaining contents are formatted. The
first line is added back before returning the formatted output.

[1]: https://docs.python.org/dev/using/cmdline.html#cmdoption-x

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Add tests for `--skip-source-first-line` option

When the flag is disabled (default), black formats the entire source
file, as in every line. In the other hand, if the flag is enabled, by
using `-x` or `--skip-source-first-line`, the first line is retained
while the rest of the source is formatted and then is added back.

These tests use an empty Python file that contains invalid syntax in
its first line (`invalid_header.py`, at `miscellaneous/`). First,
Black is invoked without enabling the flag which should result in an
exit code different than 0. When the flag is enabled, Black is
expected to return a successful exit code and the header is expected
to be retained (even if its not valid Python syntax).

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Support skip source first line option for blackd

The recently added option can be added as an acceptable header for
blackd. The arguments are passed in such a way that using the new
header will activate the skip source first line behaviour as expected

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Add skip source first line option to blackd docs

The new option can be passed to blackd as a header. This commit
updates the blackd docs to include the new header.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Update CHANGES.md

Include the new Black option to skip the first line of source code in
the configuration section

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Update skip first line test including valid syntax

Including valid Python syntax help us make sure that the file is still
actually valid after skipping the first line of the source file (which
contains invalid Python syntax)

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Skip first source line at `format_file_in_place`

Instead of skipping the first source line at `format_file_contents`,
do it before. This allow us to find the correct newline and encoding
on the actual source code (everything that's after the header).

This change is also applied at Blackd: take the header before passing
the source to `format_file_contents` and put the header back once we
get the formatted result.

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Test output newlines when skipping first line

When skipping the first line of source code, the reference newline must
be taken from the second line of the file instead of the first one, in
case that the file mixes more than one kind of newline character

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Test that Blackd also skips first line correctly

Simliarly to the Black tests, we first compare that Blackd fails when
the first line is invalid Python syntax and then check that the result
is the expected when tha flag is activated

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>

* Use the content encoding to decode the header

When decoding the header to put it back at the top of the contents of
the file, use the same encoding used in the content. This should be a
better "guess" that using the default value

Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
2022-10-06 15:17:32 -07:00
Ofek Lev
468ceafca5
Switch build backend to Hatchling (#3233)
This implements PEP 621, obviating the need for `setup.py`, `setup.cfg`,
and `MANIFEST.in`. The build backend Hatchling (of which I am a
maintainer in the PyPA) is now used as that is the default in the
official Python packaging tutorial. Hatchling is available on all the
major distribution channels such as Debian, Fedora, and many more.

## Python support

The earliest supported Python 3 version of Hatchling is 3.7, therefore
I've also set that as the minimum here. Python 3.6 is EOL and other
build backends like flit-core and setuptools also dropped support.
Python 3.6 accounted for 3-4% of downloads in the last month.

## Plugins 

Configuration is now completely static with the help of 3 plugins:

### Readme

hynek's hatch-fancy-pypi-readme allows for the dynamic construction of
the readme which was previously coded up in `setup.py`. Now it's simply:

```toml
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
fragments = [
  { path = "README.md" },
  { path = "CHANGES.md" },
]
```

### Versioning

hatch-vcs is currently just a wrapper around setuptools-scm (which
despite the legacy naming is actually now decoupled from setuptools):

```toml
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/_black_version.py"
template = '''
version = "{version}"
'''
```

### mypyc

hatch-mypyc offers many benefits over the existing approach:

- No need to manually select files for inclusion
- Avoids the need for the current CI workaround for https://github.com/mypyc/mypyc/issues/946
- Intermediate artifacts (like `build/`) from setuptools and mypyc
  itself no longer clutter the project directory
- Runtime dependencies required at build time no longer need to be
  manually redeclared as this is a built-in option of Hatchling

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-09-25 17:54:33 -04:00
Richard Si
2018e667a6
Prepare docs for release 22.8.0 (#3248) 2022-08-31 18:39:54 -04:00
Alexandr Artemyev
07b68e2425
add preview option support for blackd (#3217)
Fixes #3195

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2022-08-12 20:23:02 -07:00
onescriptkid
b0eed7c6bd
Fix typo in config docs for --extend-exclude (#3170)
The old regex in the example was invalid and caused an error on startup.
2022-07-14 19:51:18 -04:00
Nimrod
8900e3ac8a
Add warning to not run blackd publicly in docs (#3167)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-07-14 15:22:29 -04:00