Skip to content

Commit

Permalink
Update docs, tox, and package metadata (#105)
Browse files Browse the repository at this point in the history
- use `tox-uv`
- Update mypy overloads to use `...` where value doesn't need to be set
- Fix note about correct compression
- add py312 testing (fix flake8 config)
  • Loading branch information
cthoyt authored Mar 12, 2024
1 parent 85abe79 commit a364fdc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.11" ]
python-version: [ "3.8", "3.12" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install tox
run: pip install tox tox-uv
- name: Check manifest
run: tox run -e manifest
- name: Check code quality with flake8
Expand All @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.11" ]
python-version: [ "3.8", "3.12" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -43,7 +43,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install tox
pip install tox tox-uv
sudo apt-get install graphviz
- name: Check RST conformity with doc8
run: tox run -e doc8
Expand All @@ -57,7 +57,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.8", "3.11" ]
python-version: [ "3.8", "3.12" ]
pydantic: [ "1", "2" ]
steps:
- uses: actions/checkout@v2
Expand All @@ -66,7 +66,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install tox
run: pip install tox tox-uv
- name: Test with pytest and generate coverage file
run:
tox run -e py-pydantic${{ matrix.pydantic }}
Expand Down
22 changes: 15 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ license_files =

# Search tags
classifiers =
Development Status :: 1 - Planning
Development Status :: 5 - Production/Stable
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Expand All @@ -41,6 +41,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3 :: Only
keywords =
snekpack
Expand All @@ -49,6 +50,7 @@ keywords =
compact uniform resource identifiers
uniform resource identifiers
curies
IRIs

[options]
install_requires =
Expand Down Expand Up @@ -138,14 +140,20 @@ strictness = short
#########################
[flake8]
ignore =
S301 # pickle
S403 # pickle
# pickle
S301
# pickle
S403
S404
S603
W503 # Line break before binary operator (conflicts with black)
E704 # Multiple statements on one line (conflicts with black)
E203 # whitespace before ':' (conflicts with black)
S113 # Requests call without timeout
# Line break before binary operator (conflicts with black)
W503
# Multiple statements on one line (conflicts with black)
E704
# whitespace before ':' (conflicts with black)
E203
# Requests call without timeout
S113
exclude =
.tox,
.git,
Expand Down
36 changes: 19 additions & 17 deletions src/curies/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ def is_uri(self, s: str) -> bool:
# docstr-coverage:excused `overload`
@overload
def compress_or_standardize(
self, uri_or_curie: str, *, strict: Literal[True] = True, passthrough: bool = False
self, uri_or_curie: str, *, strict: Literal[True] = True, passthrough: bool = ...
) -> str: ...

# docstr-coverage:excused `overload`
Expand Down Expand Up @@ -1114,7 +1114,7 @@ def compress_strict(self, uri: str) -> str:
# docstr-coverage:excused `overload`
@overload
def compress(
self, uri: str, *, strict: Literal[True] = True, passthrough: bool = False
self, uri: str, *, strict: Literal[True] = True, passthrough: bool = ...
) -> str: ...

# docstr-coverage:excused `overload`
Expand Down Expand Up @@ -1144,16 +1144,27 @@ def compress(
:raises CompressionError:
If strict is set to true and the URI can't be compressed
>>> from curies import Converter
>>> converter = Converter.from_prefix_map({
... "CHEBI": "http://purl.obolibrary.org/obo/CHEBI_",
... "MONDO": "http://purl.obolibrary.org/obo/MONDO_",
... "GO": "http://purl.obolibrary.org/obo/GO_",
... "OBO": "http://purl.obolibrary.org/obo/",
... })
>>> converter.compress("http://purl.obolibrary.org/obo/CHEBI_138488")
'CHEBI:138488'
>>> converter.compress("http://purl.obolibrary.org/obo/GO_0032571")
'GO:0032571'
>>> converter.compress("http://purl.obolibrary.org/obo/go.owl")
'OBO:go.owl'
>>> converter.compress("http://example.org/missing:0000000")
.. note::
If there are partially overlapping *URI prefixes* in this converter
(e.g., ``http://purl.obolibrary.org/obo/GO_`` for the prefix ``GO`` and
``http://purl.obolibrary.org/obo/`` for the prefix ``OBO``), the longest
URI prefix will always be matched. For example, parsing
``http://purl.obolibrary.org/obo/GO_0032571`` will return ``GO:0032571``
instead of ``OBO:GO_0032571``.
"""
prefix, identifier = self.parse_uri(uri)
if prefix and identifier:
Expand Down Expand Up @@ -1221,7 +1232,7 @@ def is_curie(self, s: str) -> bool:
# docstr-coverage:excused `overload`
@overload
def expand_or_standardize(
self, curie_or_uri: str, *, strict: Literal[True] = True, passthrough: bool = False
self, curie_or_uri: str, *, strict: Literal[True] = True, passthrough: bool = ...
) -> str: ...

# docstr-coverage:excused `overload`
Expand Down Expand Up @@ -1300,7 +1311,7 @@ def expand_strict(self, curie: str) -> str:
# docstr-coverage:excused `overload`
@overload
def expand(
self, curie: str, *, strict: Literal[True] = True, passthrough: bool = False
self, curie: str, *, strict: Literal[True] = True, passthrough: bool = ...
) -> str: ...

# docstr-coverage:excused `overload`
Expand All @@ -1325,7 +1336,7 @@ def expand(
:param strict: If true and the CURIE can't be expanded, returns an error. Defaults to false.
:param passthrough: If true, strict is false, and the CURIE can't be expanded, return the input.
Defaults to false. If your strings can either be a CURIE _or_ a URI, consider using
:meth:`Converter.expand_ambiguous` instead.
:meth:`Converter.expand_or_standardize` instead.
:returns:
A URI if this converter contains a URI prefix for the prefix in this CURIE
:raises ExpansionError:
Expand All @@ -1340,15 +1351,6 @@ def expand(
>>> converter.expand("CHEBI:138488")
'http://purl.obolibrary.org/obo/CHEBI_138488'
>>> converter.expand("missing:0000000")
.. note::
If there are partially overlapping *URI prefixes* in this converter
(e.g., ``http://purl.obolibrary.org/obo/GO_`` for the prefix ``GO`` and
``http://purl.obolibrary.org/obo/`` for the prefix ``OBO``), the longest
URI prefix will always be matched. For example, parsing
``http://purl.obolibrary.org/obo/GO_0032571`` will return ``GO:0032571``
instead of ``OBO:GO_0032571``.
"""
prefix, identifier = self.parse_curie(curie)
rv = self.expand_pair(prefix, identifier)
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ description = Check that the MANIFEST.in is written properly and give feedback o
skip_install = true
deps =
darglint
flake8<5.0.0
flake8
flake8-black
flake8-bandit
flake8-bugbear
Expand All @@ -110,7 +110,9 @@ commands = pyroma --min=10 .
description = Run the pyroma tool to check the package friendliness of the project.

[testenv:mypy]
deps = mypy
deps =
mypy
types-requests
skip_install = true
commands = mypy --install-types --non-interactive --ignore-missing-imports --strict src/
description = Run the mypy tool to check static typing on the project.
Expand Down

0 comments on commit a364fdc

Please sign in to comment.