Skip to content

Commit 213d1b2

Browse files
authored
Restore requirements-txt-fixer in pre-commit (#7808)
1 parent 2a3eaa1 commit 213d1b2

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ repos:
4545
exclude: >-
4646
^docs/[^/]*\.svg$
4747
- id: requirements-txt-fixer
48-
exclude: >-
49-
^requirements/.*\.txt$
48+
files: requirements/.*\.in$
5049
- id: trailing-whitespace
5150
- id: file-contents-sorter
5251
args: ['--ignore-case']

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,4 @@ install-dev: .develop
187187
.PHONY: sync-direct-runtime-deps
188188
sync-direct-runtime-deps:
189189
@echo Updating 'requirements/runtime-deps.in' from 'setup.cfg'... >&2
190-
@echo '# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`' > requirements/runtime-deps.in
191-
@echo >> requirements/runtime-deps.in
192-
@python -c 'from configparser import ConfigParser; from itertools import chain; from pathlib import Path; cfg = ConfigParser(); cfg.read_string(Path("setup.cfg").read_text()); print("\n".join(line.strip() for line in chain(cfg["options"].get("install_requires").splitlines(), "\n".join(cfg["options.extras_require"].values()).splitlines()) if line.strip()))' \
193-
>> requirements/runtime-deps.in
190+
@python requirements/sync-direct-runtime-deps.py

requirements/runtime-deps.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`
22

3-
multidict >=4.5, < 7.0
4-
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
5-
yarl >= 1.0, < 2.0
6-
frozenlist >= 1.1.1
7-
aiosignal >= 1.1.2
83
aiodns >= 1.1; sys_platform=="linux" or sys_platform=="darwin"
4+
aiosignal >= 1.1.2
5+
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
96
Brotli; platform_python_implementation == 'CPython'
107
brotlicffi; platform_python_implementation != 'CPython'
8+
frozenlist >= 1.1.1
9+
multidict >=4.5, < 7.0
10+
yarl >= 1.0, < 2.0
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
"""Sync direct runtime dependencies from setup.cfg to runtime-deps.in."""
3+
4+
from configparser import ConfigParser
5+
from pathlib import Path
6+
7+
cfg = ConfigParser()
8+
cfg.read(Path("setup.cfg"))
9+
reqs = cfg["options"]["install_requires"] + cfg.items("options.extras_require")[0][1]
10+
reqs = sorted(reqs.split("\n"), key=str.casefold)
11+
reqs.remove("")
12+
13+
with open(Path("requirements", "runtime-deps.in"), "w") as outfile:
14+
header = "# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`\n\n"
15+
outfile.write(header)
16+
outfile.write("\n".join(reqs) + "\n")

requirements/test.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-r base.in
21
-c broken-projects.in
2+
-r base.in
33

44
coverage
55
mypy; implementation_name == "cpython"

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ zip_safe = False
4747
include_package_data = True
4848

4949
install_requires =
50-
multidict >=4.5, < 7.0
50+
aiosignal >= 1.1.2
5151
async-timeout >= 4.0, < 5.0 ; python_version < "3.11"
52-
yarl >= 1.0, < 2.0
5352
frozenlist >= 1.1.1
54-
aiosignal >= 1.1.2
53+
multidict >=4.5, < 7.0
54+
yarl >= 1.0, < 2.0
5555

5656
[options.exclude_package_data]
5757
* =

0 commit comments

Comments
 (0)