Skip to content

Commit 0a601df

Browse files
mjohanse-emrMichael Johansenbkeryan
authored
Simplify the public numpy dependency (#172)
* Simplify the public numpy dependency Signed-off-by: Michael Johansen <[email protected]> * Update the pin oldest deps script to also handle dev dependencies. Signed-off-by: Michael Johansen <[email protected]> * Ignore the mypy index error. Signed-off-by: Michael Johansen <[email protected]> * Change the pin_oldest_deps script to delete duplicate dependencies in dev.deps. Signed-off-by: Michael Johansen <[email protected]> * Update scripts/pin_oldest_deps.py Co-authored-by: Brad Keryan <[email protected]> --------- Signed-off-by: Michael Johansen <[email protected]> Co-authored-by: Michael Johansen <[email protected]> Co-authored-by: Brad Keryan <[email protected]>
1 parent c2fe7de commit 0a601df

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ packages = [{ include = "nitypes", from = "src" }]
3030

3131
[tool.poetry.dependencies]
3232
python = "^3.9"
33+
numpy = ">=1.22"
34+
hightime = { version = ">=0.2.2", allow-prereleases = true }
35+
typing-extensions = ">=4.13.2"
36+
37+
[tool.poetry.group.dev.dependencies]
3338
numpy = [
3439
{ version = ">=1.22", python = ">=3.9,<3.12", markers = "implementation_name != 'pypy'" },
3540
{ version = ">=1.26", python = ">=3.12,<3.13", markers = "implementation_name != 'pypy'" },
3641
{ version = ">=2.1", python = "^3.13", markers = "implementation_name != 'pypy'" },
3742
{ version = ">=2.1", python = ">=3.10,<3.11", markers = "implementation_name == 'pypy'" },
3843
{ version = ">=2.3", python = "^3.11", markers = "implementation_name == 'pypy'" },
3944
]
40-
hightime = { version = ">=0.2.2", allow-prereleases = true }
41-
typing-extensions = ">=4.13.2"
4245

4346
[tool.poetry.group.lint.dependencies]
4447
bandit = { version = ">=1.7", extras = ["toml"] }

scripts/pin_oldest_deps.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,28 @@ def main(args: list[str]) -> int | str | None:
1515
if args:
1616
return f"Unsupported arguments: {args!r}"
1717
pyproject = tomlkit.loads(pyproject_path.read_text())
18+
1819
poetry_deps = pyproject["tool"]["poetry"]["dependencies"] # type: ignore[index]
1920
assert isinstance(poetry_deps, AbstractTable)
21+
_pin_oldest_for_deps_list(poetry_deps)
22+
23+
dev_deps = pyproject["tool"]["poetry"]["group"]["dev"]["dependencies"] # type: ignore[index]
24+
assert isinstance(dev_deps, AbstractTable)
25+
_remove_duplicate_dev_deps(poetry_deps, dev_deps)
26+
27+
pyproject_path.write_text(tomlkit.dumps(pyproject))
28+
print("Updated pyproject.toml with pinned dependencies.")
29+
return None
2030

21-
for dep, value in poetry_deps.items():
31+
32+
def _pin_oldest_for_deps_list(deps_list: AbstractTable) -> None:
33+
for dep, value in deps_list.items():
2234
if dep == "python":
2335
continue
2436
if isinstance(value, str) and (
2537
value.startswith("^") or value.startswith("~") or value.startswith(">=")
2638
):
27-
poetry_deps[dep] = "==" + value.lstrip("^~>=")
39+
deps_list[dep] = "==" + value.lstrip("^~>=")
2840
elif isinstance(value, Array):
2941
for constraint in value:
3042
if "version" in constraint and (
@@ -34,9 +46,11 @@ def main(args: list[str]) -> int | str | None:
3446
):
3547
constraint["version"] = "==" + constraint["version"].lstrip("^~>=")
3648

37-
pyproject_path.write_text(tomlkit.dumps(pyproject))
38-
print("Updated pyproject.toml with pinned dependencies.")
39-
return None
49+
50+
def _remove_duplicate_dev_deps(poetry_deps: AbstractTable, dev_deps: AbstractTable) -> None:
51+
for dep, _ in poetry_deps.items():
52+
if dep in dev_deps:
53+
del dev_deps[dep]
4054

4155

4256
if __name__ == "__main__":

0 commit comments

Comments
 (0)