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

uv work: implement oldest dependencies into pyproject.toml #810

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
25 changes: 14 additions & 11 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
- name: Build wheel distribution
run: uv build --wheel
run: |
uv sync --all-packages
Copy link
Owner

Choose a reason for hiding this comment

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

Why is uv sync --all-packages needed before running uv build?

Seems unrelated to testing with oldest dependencies?

uv build --wheel
- name: Upload wheel for other jobs
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -69,7 +71,7 @@ jobs:
source venv/bin/activate
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
export NIX_SSL_CERT_FILE=$cert_file
pip install "${{needs.build-wheel.outputs.wheel-path}}[test]"
pip install "${{needs.build-wheel.outputs.wheel-path}}[dev]"
# Run tests in installed package to avoid plugin import issue:
pytest $(python -c "
import os, darker
Expand Down Expand Up @@ -105,38 +107,39 @@ jobs:
include:
- os: ubuntu-latest
python-version: '3.9'
constraints: '--constraint constraints-oldest.txt'
post_install: uv sync --resolution lowest-direct
- os: ubuntu-latest
python-version: '3.12'
post_install: pip uninstall -y -r constraints-future.txt ;
pip install -r constraints-future.txt
--upgrade --upgrade-strategy=eager
post_install: uv sync --upgrade

needs:
- build-wheel
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# need full history since Pytest runs Darker itself below
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v4
- name: Install Darker and its dependencies from the wheel built earlier
run: pip install "${{needs.build-wheel.outputs.wheel-path}}[test]"
run: pip install "${{needs.build-wheel.outputs.wheel-path}}[dev]"
${{ matrix.upgrade }} ${{ matrix.constraints }}
- name: Downgrade target-version when running oldest supported Black
if: matrix.constraints == '--constraint constraints-oldest.txt'
run: |
sed -i 's/, "py311", "py312"//' pyproject.toml
- name: Upgrade Black, Flynt and Isort from GitHub if future constraints are used
# This can't be done in the same Pip invocation as installing Darker
# since Darker might place an upper limit on Black, Flynt and/or Isort during
# compatibility fixing periods.
if: matrix.post_install
run: ${{ matrix.post_install }}
- name: Downgrade target-version when running oldest supported Black
if: matrix.constraints == '--constraint constraints-oldest.txt'
run: |
sed -i 's/, "py311", "py312"//' pyproject.toml
clintonsteiner marked this conversation as resolved.
Show resolved Hide resolved
- run: pytest

build-sdist-validate-dists:
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/test-future.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@ jobs:
with:
ref: 'master'
fetch-depth: 0
- uses: actions/setup-python@v5
clintonsteiner marked this conversation as resolved.
Show resolved Hide resolved
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
# strict dependency resolution added in pip 20.3
# CVE-2021-3572 fixed in pip 21.1
python -m pip install --upgrade 'pip>=21.1'
pip install \
--constraint=constraints-future.txt \
--upgrade \
--upgrade-strategy=eager \
-e '.[test]'
run: uv sync --upgrade --latest
- name: Test with pytest
run: |
pytest
run: uv run pytest
- name: Note a possible Black incompatibility and required actions
if: failure()
shell: python
Expand All @@ -44,7 +36,7 @@ jobs:

from packaging.version import Version

for linenum, line in enumerate(open("setup.cfg"), 1):
for linenum, line in enumerate(open("pyproject.toml"), 1):
constraint = line.strip()
if constraint.startswith("black>="):
column = line.index("black>=") + 1
Expand Down
10 changes: 0 additions & 10 deletions constraints-future.txt

This file was deleted.

24 changes: 0 additions & 24 deletions constraints-oldest.txt

This file was deleted.

90 changes: 90 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,96 @@
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"] # PEP 508 specifications.

[project]
name = "darker"
version = "2.1.1"
authors = [{name = "Antti Kaihola", email = "[email protected]"}]
license = {text = "BSD"}
description = "Apply Black formatting only in regions changed since last commit"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.9"
dependencies = [
"black>=24.10.0",
"darkgraylib~=2.2.0",
"toml>=0.10.0",
"typing_extensions>=4.0.1",
"darkgray-dev-tools",
"defusedxml>=0.7.1",
"flynt>=0.76",
"isort>=5.0.1",
"mypy>=0.990",
"packaging",
"pathspec", # to test `gen_python_files` in `test_black_diff.py`
"pydocstyle",
"pygments>=2.4.0",
"pyupgrade>=2.31.0",
"pylint>=3.2.7",
"pylint-per-file-ignores",
"pytest>=6.2.0",
"pytest-kwparametrize>=0.0.3",
"pyupgrade>=2.31.0",
"regex>=2021.4.4",
"requests_cache>=0.7",
"ruamel.yaml>=0.17.21",
"ruff>=0.0.292",
"twine>=2.0.0",
"types-requests>=2.27.9",
"types-toml>=0.10.4",
"wheel>=0.21.0",
"astor>=0.8.1",
]
dynamic = ["readme"]

[dependency-groups]
dev = [
"black>=22.3.0",
"darkgray-dev-tools~=0.1.1",
"defusedxml>=0.7.1",
"flynt>=0.76",
"isort>=5.0.1",
"mypy>=0.990",
"packaging",
"pathspec", # to test `gen_python_files` in `test_black_diff.py`
"pydocstyle",
"pygments>=2.4.0",
"pyupgrade>=2.31.0",
"pylint>=3.2.7",
"pylint-per-file-ignores",
"pytest>=6.2.0",
"pytest-kwparametrize>=0.0.3",
"pyupgrade>=2.31.0",
"regex>=2021.4.4",
"requests_cache>=0.7",
"ruamel.yaml>=0.17.21",
"ruff>=0.0.292",
"twine>=2.0.0",
"types-requests>=2.27.9",
"types-toml>=0.10.4",
"wheel>=0.21.0",
"astor>=0.8.1",
]

[project.urls]
Homepage = "https://github.com/akaihola/darker"
"Source Code" = "https://github.com/akaihola/darker"
"Change Log" = "https://github.com/akaihola/darker/blob/master/CHANGES.rst"
News = "https://github.com/akaihola/darker/discussions/categories/announcements"

[project.entry-points."darker.formatter"]
black = "darker.formatters.black_formatter:BlackFormatter"
ruff = "darker.formatters.ruff_formatter:RuffFormatter"
pyupgrade = "darker.formatters.pyupgrade_formatter:PyupgradeFormatter"
none = "darker.formatters.none_formatter:NoneFormatter"

[project.scripts]
darker = "darker.__main__:main_with_error_handling"

[tool.black]
# Darker makes Black read its configuration from the file indicated by the `--config`
# option, so we need to mirror the same configuration here and in `check-darker.toml`.
Expand Down
71 changes: 0 additions & 71 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
[metadata]
name = darker
version = attr: darker.version.__version__
author = Antti Kaihola
author_email = [email protected]
license = BSD
license_file = LICENSE.rst
description = Apply Black formatting only in regions changed since last commit
# long_description is read and manipulated in setup.py
long_description_content_type = text/x-rst
classifiers =
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
project_urls =
Source Code = https://github.com/akaihola/darker
Change Log = https://github.com/akaihola/darker/blob/master/CHANGES.rst
News = https://github.com/akaihola/darker/discussions/categories/announcements
url = https://github.com/akaihola/darker

[options]
include_package_data = True
package_dir =
Expand All @@ -42,55 +20,6 @@ darker =
py.typed
.pyi

[options.entry_points]
darker.formatter =
black = darker.formatters.black_formatter:BlackFormatter
ruff = darker.formatters.ruff_formatter:RuffFormatter
pyupgrade = darker.formatters.pyupgrade_formatter:PyupgradeFormatter
none = darker.formatters.none_formatter:NoneFormatter
console_scripts =
darker = darker.__main__:main_with_error_handling

[options.extras_require]
black =
black>=22.3.0
flynt =
flynt>=0.76
isort =
isort>=5.0.1
color =
Pygments>=2.4.0
pyupgrade =
pyupgrade>=2.31.0
test =
# NOTE: remember to keep `constraints-oldest.txt` in sync with these
black>=22.3.0
cryptography>=3.3.2 # through twine, fixes CVE-2020-36242
defusedxml>=0.7.1
flynt>=0.76
isort>=5.0.1
mypy>=0.990
packaging
pathspec # to test `gen_python_files` in `test_black_diff.py`
pydocstyle
pygments
pylint<=3.2.7 # pylint 3.3.0 dropped Python 3.8 support
pylint-per-file-ignores
pytest>=6.2.0
pytest-kwparametrize>=0.0.3
pyupgrade>=2.31.0
regex>=2021.4.4
requests_cache>=0.7
ruamel.yaml>=0.17.21
ruff>=0.0.292
twine>=2.0.0
types-requests>=2.27.9
types-toml>=0.10.4
urllib3>=1.25.9 # through requests-cache and twine, fixes CVE-2020-26137
wheel>=0.21.0
release =
darkgray-dev-tools~=0.1.1

[flake8]
# Line length according to Black rules
max-line-length = 88
Expand Down
Loading