Fixes
Here are a couple common use cases:
Addressing error in pre-commit yaml
.pre-commit-config.yaml
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
If the issue persists in pre-commit, it's likely because an old version is being cached (as suggested here). Run pre-commit clean
then pre-commit install
to reset
Addressing error in pyprojct toml
pyproject.toml
[tool.poetry.dev-dependencies]
black = {version = "^22.3.0", allow-prereleases = true}
[tool.black]
# https://github.com/psf/black
target-version = ["py39"]
line-length = 120
color = true
Example
requires pyproject.toml
above
Using Makefile & Poetry
Makefile
#* Poetry
.PHONY: poetry-download
poetry-download:
curl -sSL https://install.python-poetry.org | $(PYTHON) -
.PHONY: pre-commit-install
pre-commit-install:
poetry run pre-commit install
#* Formatters
.PHONY: codestyle
codestyle:
poetry run black --config pyproject.toml ./
.pre-commit-config.yaml
default_language_version:
python: python3.9
default_stages: [commit, push]
repos:
- repo: local
hooks:
- id: black
name: black
entry: poetry run black --config pyproject.toml
types: [python]
language: system
GitHub links
The dependency conflict is described in detail in the following links
black
version 2 days before the question was even asked, so not even "the most recent version at that time" is a sensible guess. – Hamelin