From a364fdcd6f114ae301a228cb23b33dc217d498e0 Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Tue, 12 Mar 2024 08:39:28 +0100 Subject: [PATCH] Update docs, tox, and package metadata (#105) - 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) --- .github/workflows/tests.yml | 12 ++++++------ setup.cfg | 22 +++++++++++++++------- src/curies/api.py | 36 +++++++++++++++++++----------------- tox.ini | 6 ++++-- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5e83b4c1..6c54b268 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,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 }} @@ -20,7 +20,7 @@ jobs: 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 @@ -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 }} @@ -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 @@ -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 @@ -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 }} diff --git a/setup.cfg b/setup.cfg index fbbb60b4..5d4b5060 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 @@ -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 @@ -49,6 +50,7 @@ keywords = compact uniform resource identifiers uniform resource identifiers curies + IRIs [options] install_requires = @@ -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, diff --git a/src/curies/api.py b/src/curies/api.py index 730d4e6a..26de74f0 100644 --- a/src/curies/api.py +++ b/src/curies/api.py @@ -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` @@ -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` @@ -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: @@ -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` @@ -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` @@ -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: @@ -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) diff --git a/tox.ini b/tox.ini index 68f43543..567dbdde 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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.