diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2023-11-06 19:22:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-06 10:22:29 -0800 |
commit | 1235084c20f1efabbca680c03f9f4dc023b44c5d (patch) | |
tree | 9ffad09e95686a17ca7cc030a5bc4eb1530dd1b5 /var | |
parent | b5538960c325a849bddc35506e4c219cee40a1d8 (diff) | |
download | spack-1235084c20f1efabbca680c03f9f4dc023b44c5d.tar.gz spack-1235084c20f1efabbca680c03f9f4dc023b44c5d.tar.bz2 spack-1235084c20f1efabbca680c03f9f4dc023b44c5d.tar.xz spack-1235084c20f1efabbca680c03f9f4dc023b44c5d.zip |
Introduce `default_args` context manager (#39964)
This adds a rather trivial context manager that lets you deduplicate repeated
arguments in directives, e.g.
```python
depends_on("py-x@1", when="@1", type=("build", "run"))
depends_on("py-x@2", when="@2", type=("build", "run"))
depends_on("py-x@3", when="@3", type=("build", "run"))
depends_on("py-x@4", when="@4", type=("build", "run"))
```
can be condensed to
```python
with default_args(type=("build", "run")):
depends_on("py-x@1", when="@1")
depends_on("py-x@2", when="@2")
depends_on("py-x@3", when="@3")
depends_on("py-x@4", when="@4")
```
The advantage is it's clear for humans, the downside it's less clear for type checkers due to type erasure.
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/py-black/package.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/var/spack/repos/builtin/packages/py-black/package.py b/var/spack/repos/builtin/packages/py-black/package.py index bb6539d715..825d37a446 100644 --- a/var/spack/repos/builtin/packages/py-black/package.py +++ b/var/spack/repos/builtin/packages/py-black/package.py @@ -37,23 +37,24 @@ class PyBlack(PythonPackage): depends_on("py-hatchling@1.8:", when="@22.10:", type="build") depends_on("py-hatch-vcs", when="@22.10:", type="build") depends_on("py-hatch-fancy-pypi-readme", when="@22.10:", type="build") - depends_on("python@3.8:", when="@23.7:", type=("build", "run")) - # Needed to ensure that Spack can bootstrap black with Python 3.6 - depends_on("python@3.7:", when="@22.10:", type=("build", "run")) - depends_on("py-click@8:", type=("build", "run")) - depends_on("py-mypy-extensions@0.4.3:", type=("build", "run")) - depends_on("py-packaging@22:", when="@23.1:", type=("build", "run")) - depends_on("py-pathspec@0.9:", type=("build", "run")) - depends_on("py-platformdirs@2:", type=("build", "run")) - depends_on("py-tomli@1.1:", when="@22.8: ^python@:3.10", type=("build", "run")) - depends_on("py-tomli@1.1:", when="@21.7:22.6", type=("build", "run")) - depends_on("py-typing-extensions@3.10:", when="^python@:3.9", type=("build", "run")) - - depends_on("py-colorama@0.4.3:", when="+colorama", type=("build", "run")) - depends_on("py-uvloop@0.15.2:", when="+uvloop", type=("build", "run")) - depends_on("py-aiohttp@3.7.4:", when="+d", type=("build", "run")) - depends_on("py-ipython@7.8:", when="+jupyter", type=("build", "run")) - depends_on("py-tokenize-rt@3.2:", when="+jupyter", type=("build", "run")) + + with default_args(type=("build", "run")): + depends_on("python@3.8:", when="@23.7:") + depends_on("python@3.7:", when="@22.10:") + depends_on("py-click@8:") + depends_on("py-mypy-extensions@0.4.3:") + depends_on("py-packaging@22:", when="@23.1:") + depends_on("py-pathspec@0.9:") + depends_on("py-platformdirs@2:") + depends_on("py-tomli@1.1:", when="@22.8: ^python@:3.10") + depends_on("py-tomli@1.1:", when="@21.7:22.6") + depends_on("py-typing-extensions@3.10:", when="^python@:3.9") + + depends_on("py-colorama@0.4.3:", when="+colorama") + depends_on("py-uvloop@0.15.2:", when="+uvloop") + depends_on("py-aiohttp@3.7.4:", when="+d") + depends_on("py-ipython@7.8:", when="+jupyter") + depends_on("py-tokenize-rt@3.2:", when="+jupyter") # Historical dependencies depends_on("py-setuptools@45:", when="@:22.8", type=("build", "run")) |