Skip to content

Commit 4e55236

Browse files
authored
Update cruft and mypy (#73)
1 parent f36747c commit 4e55236

7 files changed

Lines changed: 94 additions & 44 deletions

File tree

.cruft.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/cthoyt/cookiecutter-snekpack",
3-
"commit": "a6f6b5681f77004e7714efb00895d7b5983eb4c3",
3+
"commit": "3257f18b9b5dc6922830dea64f9e0ab8b42a40e4",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -18,10 +18,12 @@
1818
"__runner": "tox -e",
1919
"__runner_uv": "--with tox-uv tox -e",
2020
"__runner_pip": "tox tox-uv",
21+
"__runner_install_uv": "uv tool install tox --with tox-uv",
22+
"__runner_install_pip": "python3 -m pip install tox tox-uv",
2123
"__runner_tests": "py",
2224
"__gh_slug": "biopragmatics/bioversions",
2325
"_template": "https://github.com/cthoyt/cookiecutter-snekpack",
24-
"_commit": "a6f6b5681f77004e7714efb00895d7b5983eb4c3"
26+
"_commit": "3257f18b9b5dc6922830dea64f9e0ab8b42a40e4"
2527
}
2628
},
2729
"directory": null

README.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ While https://biopragmatics.github.io/bioversions provides a daily updated
6060
static listing of the database, you can run a dynamic version with an API from
6161
your shell with:
6262

63-
```bash
63+
```console
6464
$ bioversions web
6565
```
6666

@@ -84,25 +84,40 @@ assert res['result']['version'] == '4.2.192', 'This was true on Dec 5th, 2020!'
8484
You can use `bioversions get` to incorporate the latest versions in your shell
8585
scripts or REPL usage like in:
8686

87-
```bash
87+
```console
8888
$ wget "https://downloads.thebiogrid.org/Download/BioGRID/Release-Archive/BIOGRID-$(bioversions get biogrid)/BIOGRID-ALL-$(bioversions get biogrid).mitab.zip"
8989
```
9090

9191
## 🚀 Installation
9292

9393
The most recent release can be installed from
94-
[PyPI](https://pypi.org/project/bioversions/) with:
94+
[PyPI](https://pypi.org/project/bioversions/) with uv:
95+
96+
```console
97+
$ uv pip install bioversions
98+
```
99+
100+
or with pip:
101+
102+
```console
103+
$ python3 -m pip install bioversions
104+
```
105+
106+
The most recent code and data can be installed directly from GitHub with uv:
95107

96108
```console
97-
python3 -m pip install bioversions
109+
$ uv --preview pip install git+https://github.com/biopragmatics/bioversions.git
98110
```
99111

100-
The most recent code and data can be installed directly from GitHub with:
112+
or with pip:
101113

102114
```console
103-
python3 -m pip install git+https://github.com/biopragmatics/bioversions.git
115+
$ UV_PREVIEW=1 python3 -m pip install git+https://github.com/biopragmatics/bioversions.git
104116
```
105117

118+
Note that this requires setting `UV_PREVIEW` mode enabled until the uv build
119+
backend becomes a stable feature.
120+
106121
## 👐 Contributing
107122

108123
Contributions, whether filing an issue, making a pull request, or forking, are
@@ -168,22 +183,24 @@ $ cd bioversions
168183
$ uv --preview pip install -e .
169184
```
170185

171-
Alternatively, install using legacy pip with `UV_PREVIEW` mode enabled until the
172-
uv build backend becomes a stable feature:
186+
Alternatively, install using pip:
173187

174188
```console
175189
$ UV_PREVIEW=1 python3 -m pip install -e .
176190
```
177191

192+
Note that this requires setting `UV_PREVIEW` mode enabled until the uv build
193+
backend becomes a stable feature.
194+
178195
### Updating Package Boilerplate
179196

180197
This project uses `cruft` to keep boilerplate (i.e., configuration, contribution
181198
guidelines, documentation configuration) up-to-date with the upstream
182-
cookiecutter package. Update with the following:
199+
cookiecutter package. Install cruft with either `uv tool install cruft` or
200+
`python3 -m pip install cruft` then run:
183201

184202
```console
185-
python3 -m pip install cruft
186-
cruft update
203+
$ cruft update
187204
```
188205

189206
More info on Cruft's update command is available
@@ -192,11 +209,11 @@ More info on Cruft's update command is available
192209
### 🥼 Testing
193210

194211
After cloning the repository and installing `tox` with
195-
`python3 -m pip install tox tox-uv`, the unit tests in the `tests/` folder can
196-
be run reproducibly with:
212+
`uv tool install tox --with tox-uv` or `python3 -m pip install tox tox-uv`, the
213+
unit tests in the `tests/` folder can be run reproducibly with:
197214

198215
```console
199-
tox -e py
216+
$ tox -e py
200217
```
201218

202219
Additionally, these tests are automatically re-run with each commit in a
@@ -207,10 +224,10 @@ Additionally, these tests are automatically re-run with each commit in a
207224
The documentation can be built locally using the following:
208225

209226
```console
210-
git clone git+https://github.com/biopragmatics/bioversions.git
211-
cd bioversions
212-
tox -e docs
213-
open docs/build/html/index.html
227+
$ git clone git+https://github.com/biopragmatics/bioversions.git
228+
$ cd bioversions
229+
$ tox -e docs
230+
$ open docs/build/html/index.html
214231
```
215232

216233
The documentation automatically installs the package as well as the `docs` extra
@@ -290,10 +307,11 @@ Note that this deprecates previous workflows using `.pypirc`.
290307
#### Uploading to PyPI
291308

292309
After installing the package in development mode and installing `tox` with
293-
`python3 -m pip install tox tox-uv`, run the following from the console:
310+
`uv tool install tox --with tox-uv` or `python3 -m pip install tox tox-uv`, run
311+
the following from the console:
294312

295313
```console
296-
tox -e finish
314+
$ tox -e finish
297315
```
298316

299317
This script does the following:

docs/source/installation.rst

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
11
Installation
22
============
33
The most recent release can be installed from
4-
`PyPI <https://pypi.org/project/bioversions>`_ with:
4+
`PyPI <https://pypi.org/project/bioversions>`_ with uv:
55

6-
.. code-block:: shell
6+
.. code-block:: console
77
8-
python3 -m pip install bioversions
8+
$ uv pip install bioversions
99
10-
The most recent code and data can be installed directly from GitHub with:
10+
or with pip:
1111

12-
.. code-block:: shell
12+
.. code-block:: console
1313
14-
python3 -m pip install git+https://github.com/biopragmatics/bioversions.git
14+
$ python3 -m pip install bioversions
1515
16-
To install in development mode, use the following:
16+
Installing from git
17+
-------------------
18+
The most recent code and data can be installed directly from GitHub with uv:
1719

18-
.. code-block:: shell
20+
.. code-block:: console
1921
20-
git clone git+https://github.com/biopragmatics/bioversions.git
21-
cd bioversions
22-
UV_PREVIEW=1 python3 -m pip install -e .
22+
$ uv --preview pip install git+https://github.com/biopragmatics/bioversions.git
2323
24-
Note that the ``UV_PREVIEW`` environment variable is required to be
25-
set until the uv build backend becomes a stable feature.
24+
or with pip:
25+
26+
.. code-block:: console
27+
28+
$ UV_PREVIEW=1 python3 -m pip install git+https://github.com/biopragmatics/bioversions.git
29+
30+
.. note::
31+
32+
The ``UV_PREVIEW`` environment variable is required to be
33+
set until the uv build backend becomes a stable feature.
34+
35+
Installing for development
36+
--------------------------
37+
To install in development mode with uv:
38+
39+
.. code-block:: console
40+
41+
$ git clone git+https://github.com/biopragmatics/bioversions.git
42+
$cd bioversions
43+
$ uv --preview pip install -e .
44+
45+
or with pip:
46+
47+
.. code-block:: console
48+
49+
$ UV_PREVIEW=1 python3 -m pip install -e .

src/bioversions/sources/kegg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class KEGGGetter(Getter):
2020
name = "KEGG"
2121
date_fmt = "%B %d, %Y"
2222
version_type = VersionType.semver_minor
23-
collection: ClassVar[list[str]] = ["kegg", *bioregistry.get_has_parts("kegg")]
23+
collection: ClassVar[list[str]] = ["kegg", *(bioregistry.get_has_parts("kegg") or [])]
2424

2525
def get(self) -> Mapping[str, str]:
2626
"""Get the latest KEGG version number."""

src/bioversions/sources/ols.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Get versions from the OLS."""
22

33
import logging
4-
from collections.abc import Iterable, Mapping
4+
from collections.abc import Iterable
5+
from typing import cast
56

67
import bioregistry
78
from bioregistry.external.ols import get_ols_processing
@@ -16,9 +17,13 @@
1617

1718
def _get_version_type(bioregistry_id: str) -> VersionType | None:
1819
ols_id = bioregistry.get_ols_prefix(bioregistry_id)
20+
if ols_id is None:
21+
raise ValueError(f"Missing OLS prefix for bioregistry:{bioregistry_id}")
1922
ols_config = ols_processing.get(ols_id)
2023
if ols_config is None:
21-
raise
24+
raise ValueError(
25+
f"Missing OLS configuration for bioregistry:{bioregistry_id} / ols:{ols_id}"
26+
)
2227

2328
ols_version_type = ols_config.version_type
2429
ols_version_date_format = ols_config.version_date_format
@@ -61,12 +66,12 @@ class OlsGetter(Getter):
6166
"""A getter for OLS data from the Bioregistry."""
6267

6368
bioregistry_id = _brid
64-
name = _name
69+
name = cast(str, _name)
6570
version_type = _version_type # type:ignore
6671

67-
def get(self) -> str | Mapping[str, str]:
72+
def get(self) -> str:
6873
"""Get the version from the Bioregistry."""
69-
return version
74+
return cast(str, version)
7075

7176
return OlsGetter
7277

src/bioversions/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ class OBOFoundryGetter(Getter):
271271
@property
272272
def key(self) -> str:
273273
"""Get the OBO Foundry key."""
274+
if self.bioregistry_id is None:
275+
raise ValueError("missing bioregistry ID")
274276
rv = bioregistry.get_obofoundry_prefix(self.bioregistry_id)
275277
if rv is None:
276278
raise ValueError

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,15 @@ commands = pyroma --min=10 .
132132
description = Run the pyroma tool to check the package friendliness of the project.
133133

134134
[testenv:mypy]
135-
description = Run the mypy tool to check static typing on the project.
135+
description = Run the mypy tool to check static typing on the project. Installs the package to make sure all type stubs get recognized.
136136
deps =
137137
mypy
138138
pydantic
139139
types-PyYAML
140140
types-python-dateutil
141141
types-requests
142142
types-tabulate
143-
skip_install = true
144-
commands = mypy --install-types --non-interactive --ignore-missing-imports src/
143+
commands = mypy --ignore-missing-imports src/
145144

146145
[testenv:doc8]
147146
skip_install = true

0 commit comments

Comments
 (0)