Skip to content

Commit 1057a84

Browse files
committed
Upgrade testing dependencies, fix types
1 parent 436e5e2 commit 1057a84

File tree

9 files changed

+45
-38
lines changed

9 files changed

+45
-38
lines changed

dowsing/_demo_pep517.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
For testing, dump the requirements that we find using the pep517 project.
33
"""
4+
45
import json
56
import sys
67

@@ -19,12 +20,12 @@ def main(path: str) -> None:
1920
d = {}
2021
with BuildEnvironment() as env:
2122
env.pip_install(requires)
22-
d[
23-
"get_requires_for_build_sdist"
24-
] = requires + hooks.get_requires_for_build_sdist(None)
25-
d[
26-
"get_requires_for_build_wheel"
27-
] = requires + hooks.get_requires_for_build_wheel(None)
23+
d["get_requires_for_build_sdist"] = (
24+
requires + hooks.get_requires_for_build_sdist(None)
25+
)
26+
d["get_requires_for_build_wheel"] = (
27+
requires + hooks.get_requires_for_build_wheel(None)
28+
)
2829

2930
print(json.dumps(d))
3031

dowsing/flit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def get_metadata(self) -> Distribution:
2424

2525
d = self.get_pep621_metadata()
2626
d.entry_points = dict(d.entry_points) or {}
27+
d.project_urls = list(d.project_urls)
28+
29+
assert isinstance(d.project_urls, list)
2730

2831
flit = doc.get("tool", {}).get("flit", {})
2932
metadata = flit.get("metadata", {})
@@ -33,7 +36,7 @@ def get_metadata(self) -> Distribution:
3336
# TODO requires -> requires_dist
3437
# TODO tool.flit.metadata.urls
3538
if k == "home-page":
36-
d.project_urls["Homepage"] = v
39+
d.project_urls.append("Homepage={v}")
3740
continue
3841
elif k == "module":
3942
if (self.path / f"{v}.py").exists():

dowsing/pep621.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ def get_pep621_metadata(self) -> Distribution:
1111

1212
d = Distribution()
1313
d.metadata_version = "2.1"
14-
d.project_urls = {}
14+
d.project_urls = []
1515
d.entry_points = {}
1616
d.requires_dist = []
1717
d.packages = []
1818
d.packages_dict = {}
1919

20+
assert isinstance(d.project_urls, list)
21+
2022
table = doc.get("project", None)
2123
if table:
2224
for k, v in table.items():
@@ -40,7 +42,7 @@ def get_pep621_metadata(self) -> Distribution:
4042
elif k == "optional-dependencies":
4143
pass
4244
elif k == "urls":
43-
d.project_urls.update(v)
45+
d.project_urls.extend(v)
4446

4547
k2 = k.replace("-", "_")
4648
if k2 in d:

dowsing/poetry.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ def get_metadata(self) -> Distribution:
3636

3737
d = Distribution()
3838
d.metadata_version = "2.1"
39-
d.project_urls = {}
39+
d.project_urls = []
4040
d.entry_points = {}
4141
d.requires_dist = []
4242
d.packages = []
4343
d.packages_dict = {}
4444

45+
assert isinstance(d.project_urls, list)
46+
4547
poetry = doc.get("tool", {}).get("poetry", {})
4648
for k, v in poetry.items():
4749
if k in ("homepage", "repository", "documentation"):
48-
d.project_urls[k] = v
50+
d.project_urls.append(f"{k}={v}")
4951
elif k == "packages":
5052
# TODO improve and add tests; this works for tf2_utils and
5153
# poetry itself but include can be a glob and there are excludes
@@ -72,7 +74,7 @@ def get_metadata(self) -> Distribution:
7274
d.requires_dist.append(k) # TODO something with version
7375

7476
for k, v in poetry.get("urls", {}).items():
75-
d.project_urls[k] = v
77+
d.project_urls.append(f"{k}={v}")
7678

7779
for k, v in poetry.get("scripts", {}).items():
7880
d.entry_points[k] = v

dowsing/tests/setuptools_metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def egg_info(files: Dict[str, str]) -> Tuple[Message, Distribution]:
4343
parser = email.parser.Parser()
4444
info = parser.parse(f)
4545
reader = SetuptoolsReader(Path(d))
46-
dist = reader.get_metadata()
47-
return info, dist
46+
dist = reader.get_metadata() # type: ignore[assignment]
47+
return info, dist # type: ignore[return-value]
4848

4949

5050
# These tests do not increase coverage, and just verify that we have the right
@@ -97,8 +97,8 @@ def test_arg_mapping(self) -> None:
9797
# setuptools>=57 writes long_description to the body/payload
9898
# of PKG-INFO, and skips the description field entirely.
9999
if field.keyword == "long_description" and a is None:
100-
a = setup_py_info.get_payload()
101-
b = setup_cfg_info.get_payload()
100+
a = setup_py_info.get_payload() # type: ignore[assignment]
101+
b = setup_cfg_info.get_payload() # type: ignore[assignment]
102102

103103
# install_requires gets written out to *.egg-info/requires.txt
104104
# instead

dowsing/types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ def get_metadata(self) -> "Distribution":
3737

3838
DEFAULT_EMPTY_DICT: Mapping[str, Any] = MappingProxyType({})
3939

40-
# TODO: pkginfo isn't typed, and is doing to require a yak-shave to send a PR
41-
# since it's on launchpad.
42-
class Distribution(pkginfo.distribution.Distribution): # type: ignore
40+
41+
class Distribution(pkginfo.distribution.Distribution):
4342
# These are not actually part of the metadata, see PEP 566
4443
setup_requires: Sequence[str] = ()
4544
tests_require: Sequence[str] = ()
@@ -68,7 +67,8 @@ class Distribution(pkginfo.distribution.Distribution): # type: ignore
6867
def _getHeaderAttrs(self) -> Sequence[Tuple[str, str, bool]]:
6968
# Until I invent a metadata version to include this, do so
7069
# unconditionally.
71-
return tuple(super()._getHeaderAttrs()) + (
70+
# Stubs are wrong, this does too exist.
71+
return tuple(super()._getHeaderAttrs()) + ( # type: ignore[misc]
7272
("X-Setup-Requires", "setup_requires", True),
7373
("X-Tests-Require", "tests_require", True),
7474
("???", "extras_require", False),

requirements-dev.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
black==22.1.0
2-
click==8.0.3
3-
coverage==4.5.4
4-
flake8==3.7.9
5-
mypy==0.931
6-
tox==3.24.5
7-
twine==3.1.1
8-
ufmt==1.3.1.post1
9-
usort==1.0.1
1+
black==24.10.0
2+
click==8.1.7
3+
coverage==7.6.8
4+
flake8==7.1.1
5+
mypy==1.13.0
6+
tox==4.23.2
7+
twine==5.1.1
8+
ufmt==2.8.0
9+
usort==1.0.8.post1
1010
volatile==2.1.0
11-
wheel==0.37.1
12-
honesty==0.3.0a2
11+
wheel==0.45.1
12+
honesty==0.3.0b1

requirements.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
highlighter==0.1.1
1+
highlighter==0.2.0
22
imperfect==0.3.0
3-
LibCST==0.3.12
4-
tomlkit==0.9.0
5-
pkginfo==1.8.1
6-
dataclasses==0.8; python_version<"3.7"
3+
LibCST==1.5.1
4+
tomlkit==0.13.2
5+
pkginfo==1.11.2

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ packages =
1616
setup_requires =
1717
setuptools_scm
1818
setuptools >= 38.3.0
19-
python_requires = >=3.6
19+
python_requires = >=3.7
2020
install_requires =
2121
highlighter>=0.1.1
2222
imperfect>=0.1.0
@@ -48,7 +48,7 @@ use_parentheses = True
4848

4949
[mypy]
5050
ignore_missing_imports = True
51-
python_version = 3.7
51+
python_version = 3.8
5252
strict = True
5353

5454
[tox:tox]

0 commit comments

Comments
 (0)