From 2f916de0613a4f3aba53134769a9c76cf88b6d69 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 20:45:50 -0500 Subject: [PATCH 01/27] Added mypy to config --- Makefile | 5 ++++- env/requirements-style.txt | 4 ++++ pyproject.toml | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9d7ec156..33c2158f 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ format: black $(CHECK_STYLE) burocrata --extension=py $(CHECK_STYLE) -check: check-format check-style +check: check-format check-style check-types check-format: black --check $(CHECK_STYLE) @@ -43,6 +43,9 @@ check-format: check-style: flake8 $(CHECK_STYLE) +check-style: + mypy $(CHECK_STYLE) + lint: pylint --jobs=0 $(LINT_FILES) diff --git a/env/requirements-style.txt b/env/requirements-style.txt index 1a7e06ca..d8da6ccb 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -4,3 +4,7 @@ flake8 pylint>=2.4 pathspec burocrata +types-requests +types-tqdm +types-paramiko +mypy diff --git a/pyproject.toml b/pyproject.toml index fefd5e99..87528518 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,10 @@ dependencies = [ "requests >= 2.19.0", ] +[[tool.mypy.overrides]] +module = ["xxhash"] +ignore_missing_imports = true + [project.optional-dependencies] progress = ["tqdm>=4.41.0,<5.0.0"] sftp = ["paramiko>=2.7.0"] From da49e8d5c04c679b1feccee20be35f5f417b6dca Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 20:50:55 -0500 Subject: [PATCH 02/27] Mypy check is passing --- pooch/__init__.py | 2 +- pooch/downloaders.py | 6 ++++-- pooch/tests/test_downloaders.py | 7 +++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pooch/__init__.py b/pooch/__init__.py index 14d46b3f..c9acf973 100644 --- a/pooch/__init__.py +++ b/pooch/__init__.py @@ -19,7 +19,7 @@ from .processors import Unzip, Untar, Decompress # This file is generated automatically by setuptools_scm -from . import _version +from . import _version # type: ignore # Add a "v" to the version number diff --git a/pooch/downloaders.py b/pooch/downloaders.py index fa3b52da..552763eb 100644 --- a/pooch/downloaders.py +++ b/pooch/downloaders.py @@ -15,15 +15,17 @@ from .utils import parse_url +# Mypy doesn't like assigning None like this. +# Can just use a guard variable try: from tqdm import tqdm except ImportError: - tqdm = None + tqdm = None # type: ignore try: import paramiko except ImportError: - paramiko = None + paramiko = None # type: ignore def choose_downloader(url, progressbar=False): diff --git a/pooch/tests/test_downloaders.py b/pooch/tests/test_downloaders.py index 09cfeabd..c8029848 100644 --- a/pooch/tests/test_downloaders.py +++ b/pooch/tests/test_downloaders.py @@ -13,15 +13,18 @@ import pytest +# Mypy doesn't like assigning None like this. +# Can just use a guard variable + try: import tqdm except ImportError: - tqdm = None + tqdm = None # type: ignore try: import paramiko except ImportError: - paramiko = None + paramiko = None # type: ignore from .. import Pooch from ..downloaders import ( From 8721442adf84f64e52a28a0bda663145c07aed07 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:08:24 -0500 Subject: [PATCH 03/27] Adding hitns --- pooch/core.py | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index db1014e9..3013c579 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -13,6 +13,8 @@ from pathlib import Path import shlex import shutil +import typing as t +import typing_extensions as te from .hashes import hash_matches, file_hash @@ -27,6 +29,12 @@ ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository +FilePathT = t.Union[str, os.PathLike[str]] +ActionsT = te.Literal["download", "fetch", "update"] + +DownloaderT = t.Callable[[str, FilePathT, "Pooch"], bool] +ProcessorT = t.Callable[[str, ActionsT, "Pooch"]] + def retrieve( url, @@ -479,13 +487,13 @@ class Pooch: def __init__( self, - path, - base_url, - registry=None, - urls=None, - retry_if_failed=0, - allow_updates=True, - ): + path: str, + base_url: str, + registry: t.Optional[t.Dict[str, str]] = None, + urls: t.Optional[t.Dict[str, str]] = None, + retry_if_failed: int = 0, + allow_updates: bool = True, + ) -> None: self.path = path self.base_url = base_url if registry is None: @@ -498,16 +506,22 @@ def __init__( self.allow_updates = allow_updates @property - def abspath(self): + def abspath(self) -> Path: "Absolute path to the local storage" return Path(os.path.abspath(os.path.expanduser(str(self.path)))) @property - def registry_files(self): + def registry_files(self) -> t.List[str]: "List of file names on the registry" return list(self.registry) - def fetch(self, fname, processor=None, downloader=None, progressbar=False): + def fetch( + self, + fname: str, + processor: t.Optional[ProcessorT] = None, + downloader: t.Optional[DownloaderT] = None, + progressbar: bool = False, + ) -> str: """ Get the absolute path to a file in the local storage. @@ -600,7 +614,7 @@ def fetch(self, fname, processor=None, downloader=None, progressbar=False): return str(full_path) - def _assert_file_in_registry(self, fname): + def _assert_file_in_registry(self, fname: str) -> None: """ Check if a file is in the registry and raise :class:`ValueError` if it's not. @@ -608,7 +622,7 @@ def _assert_file_in_registry(self, fname): if fname not in self.registry: raise ValueError(f"File '{fname}' is not in the registry.") - def get_url(self, fname): + def get_url(self, fname: str) -> str: """ Get the full URL to download a file in the registry. @@ -622,7 +636,7 @@ def get_url(self, fname): self._assert_file_in_registry(fname) return self.urls.get(fname, "".join([self.base_url, fname])) - def load_registry(self, fname): + def load_registry(self, fname: FilePathT) -> None: """ Load entries from a file and add them to the registry. @@ -673,7 +687,7 @@ def load_registry(self, fname): self.urls[file_name] = file_url self.registry[file_name] = file_checksum.lower() - def load_registry_from_doi(self): + def load_registry_from_doi(self) -> None: """ Populate the registry using the data repository API @@ -703,7 +717,7 @@ def load_registry_from_doi(self): # Call registry population for this repository return repository.populate_registry(self) - def is_available(self, fname, downloader=None): + def is_available(self, fname: str, downloader: t.Optional[DownloaderT] = None): """ Check availability of a remote file without downloading it. From 85bdcbc54c092167a2eab9196387c8586a944ed4 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:23:58 -0500 Subject: [PATCH 04/27] Function annotation --- pooch/core.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 3013c579..e83b0139 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -32,8 +32,19 @@ FilePathT = t.Union[str, os.PathLike[str]] ActionsT = te.Literal["download", "fetch", "update"] -DownloaderT = t.Callable[[str, FilePathT, "Pooch"], bool] -ProcessorT = t.Callable[[str, ActionsT, "Pooch"]] + +class DownloaderT(te.Protocol): + def __call__( + self, + fname: str, + action: t.Optional[FilePathT], + pooch: "Pooch", + *, + check_only: t.Optional[bool] = None, + ) -> t.Any: ... + + +ProcessorT = t.Callable[[str, ActionsT, "Pooch"], t.Any] def retrieve( @@ -658,7 +669,7 @@ def load_registry(self, fname: FilePathT) -> None: with contextlib.ExitStack() as stack: if hasattr(fname, "read"): # It's a file object - fin = fname + fin: t.Any = fname else: # It's a file path fin = stack.enter_context(open(fname, encoding="utf-8")) From fc638b6ffbfaf25f03c25b672cc401a0580cf6a0 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:25:11 -0500 Subject: [PATCH 05/27] format --- pooch/__init__.py | 2 +- pooch/downloaders.py | 4 ++-- pooch/tests/test_downloaders.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pooch/__init__.py b/pooch/__init__.py index c9acf973..826cb57d 100644 --- a/pooch/__init__.py +++ b/pooch/__init__.py @@ -19,7 +19,7 @@ from .processors import Unzip, Untar, Decompress # This file is generated automatically by setuptools_scm -from . import _version # type: ignore +from . import _version # type: ignore # Add a "v" to the version number diff --git a/pooch/downloaders.py b/pooch/downloaders.py index 552763eb..bd95690e 100644 --- a/pooch/downloaders.py +++ b/pooch/downloaders.py @@ -20,12 +20,12 @@ try: from tqdm import tqdm except ImportError: - tqdm = None # type: ignore + tqdm = None # type: ignore try: import paramiko except ImportError: - paramiko = None # type: ignore + paramiko = None # type: ignore def choose_downloader(url, progressbar=False): diff --git a/pooch/tests/test_downloaders.py b/pooch/tests/test_downloaders.py index c8029848..8ad4e287 100644 --- a/pooch/tests/test_downloaders.py +++ b/pooch/tests/test_downloaders.py @@ -19,12 +19,12 @@ try: import tqdm except ImportError: - tqdm = None # type: ignore + tqdm = None # type: ignore try: import paramiko except ImportError: - paramiko = None # type: ignore + paramiko = None # type: ignore from .. import Pooch from ..downloaders import ( From ab683aabdc68b1f1b1dde108c0c9f20fe9d8fec9 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:28:47 -0500 Subject: [PATCH 06/27] Other hints --- doc/conf.py | 5 +++-- env/requirements-style.txt | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 6c7bb4de..1370d142 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -8,6 +8,7 @@ import datetime import pooch +import typing as t # Project information @@ -44,7 +45,7 @@ } # Autosummary pages will be generated by sphinx-autogen instead of sphinx-build -autosummary_generate = [] +autosummary_generate: t.List = [] # Otherwise, the Return parameter list looks different from the Parameters list napoleon_use_rtype = False @@ -77,7 +78,7 @@ html_static_path = ["_static"] # CSS files are relative to the static path html_css_files = ["style.css"] -html_extra_path = [] +html_extra_path: t.List = [] html_show_sourcelink = False html_show_sphinx = True html_show_copyright = True diff --git a/env/requirements-style.txt b/env/requirements-style.txt index d8da6ccb..15f55e7f 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -8,3 +8,4 @@ types-requests types-tqdm types-paramiko mypy +pytest From bea0f4b1444f2d957d823bedff640ac85460aace Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:37:56 -0500 Subject: [PATCH 07/27] Added ignores --- .github/workflows/style.yml | 22 ++++++++++++++++++++++ Makefile | 2 +- pooch/core.py | 17 +++++++++++------ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 87e9d4db..f9ad4d31 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -59,3 +59,25 @@ jobs: - name: Check code style run: make check-style lint + + style: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install requirements + run: python -m pip install -r env/requirements-style.txt + + - name: List installed packages + run: python -m pip freeze + + - name: Check code style + run: make check-types diff --git a/Makefile b/Makefile index 33c2158f..b84bbc53 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ check-format: check-style: flake8 $(CHECK_STYLE) -check-style: +check-types: mypy $(CHECK_STYLE) lint: diff --git a/pooch/core.py b/pooch/core.py index e83b0139..ed72332f 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -29,22 +29,27 @@ ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository -FilePathT = t.Union[str, os.PathLike[str]] -ActionsT = te.Literal["download", "fetch", "update"] +FilePath = t.Union[str, os.PathLike[str]] +Actions = te.Literal["download", "fetch", "update"] class DownloaderT(te.Protocol): - def __call__( + """ + A class used to define the type definition for the downloader function. + """ + + # pylint: disable=too-few-public-methods + def __call__( # noqa: E704 self, fname: str, - action: t.Optional[FilePathT], + action: t.Optional[FilePath], pooch: "Pooch", *, check_only: t.Optional[bool] = None, ) -> t.Any: ... -ProcessorT = t.Callable[[str, ActionsT, "Pooch"], t.Any] +ProcessorT = t.Callable[[str, Actions, "Pooch"], t.Any] def retrieve( @@ -647,7 +652,7 @@ def get_url(self, fname: str) -> str: self._assert_file_in_registry(fname) return self.urls.get(fname, "".join([self.base_url, fname])) - def load_registry(self, fname: FilePathT) -> None: + def load_registry(self, fname: FilePath) -> None: """ Load entries from a file and add them to the registry. From 82084c6d1926f094f0013f2603538b5f355555da Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:40:51 -0500 Subject: [PATCH 08/27] Name fix --- .github/workflows/style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index f9ad4d31..ad0de426 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -60,7 +60,7 @@ jobs: - name: Check code style run: make check-style lint - style: + types: runs-on: ubuntu-latest steps: - name: Checkout From 1f18ec8e96d1b806a3518fcefd3ea97f32de46c5 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:50:52 -0500 Subject: [PATCH 09/27] dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 87528518..b2567054 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ dependencies = [ "platformdirs >= 2.5.0", "packaging >= 20.0", "requests >= 2.19.0", + "typing_extensions >= 4.0.0", ] [[tool.mypy.overrides]] From 318aad188a88766c48f617bc7d614a8505dd109d Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Sun, 10 Mar 2024 21:55:01 -0500 Subject: [PATCH 10/27] typo fix --- pooch/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooch/core.py b/pooch/core.py index ed72332f..08532a07 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -29,7 +29,7 @@ ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository -FilePath = t.Union[str, os.PathLike[str]] +FilePath = t.Union[str, os.PathLike] Actions = te.Literal["download", "fetch", "update"] From ea4a37575130c80c73f6b9a13237ad88a862af3a Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 21:46:39 -0600 Subject: [PATCH 11/27] Remove Ts --- pooch/core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 08532a07..5b294522 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -33,7 +33,7 @@ Actions = te.Literal["download", "fetch", "update"] -class DownloaderT(te.Protocol): +class Downloader(te.Protocol): """ A class used to define the type definition for the downloader function. """ @@ -49,7 +49,7 @@ def __call__( # noqa: E704 ) -> t.Any: ... -ProcessorT = t.Callable[[str, Actions, "Pooch"], t.Any] +Processor = t.Callable[[str, Actions, "Pooch"], t.Any] def retrieve( @@ -534,8 +534,8 @@ def registry_files(self) -> t.List[str]: def fetch( self, fname: str, - processor: t.Optional[ProcessorT] = None, - downloader: t.Optional[DownloaderT] = None, + processor: t.Optional[Processor] = None, + downloader: t.Optional[Downloader] = None, progressbar: bool = False, ) -> str: """ @@ -733,7 +733,7 @@ def load_registry_from_doi(self) -> None: # Call registry population for this repository return repository.populate_registry(self) - def is_available(self, fname: str, downloader: t.Optional[DownloaderT] = None): + def is_available(self, fname: str, downloader: t.Optional[Downloader] = None): """ Check availability of a remote file without downloading it. From 29a9dbf0ee3a147190751059edf205bf443a0218 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 21:51:09 -0600 Subject: [PATCH 12/27] Change typing --- env/requirements-style.txt | 1 - environment.yml | 1 + pooch/core.py | 5 ++--- pyproject.toml | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/env/requirements-style.txt b/env/requirements-style.txt index 15f55e7f..d8da6ccb 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -8,4 +8,3 @@ types-requests types-tqdm types-paramiko mypy -pytest diff --git a/environment.yml b/environment.yml index b4d56569..fbba4eaf 100644 --- a/environment.yml +++ b/environment.yml @@ -31,5 +31,6 @@ dependencies: - black>=20.8b1 - flake8 - pylint>=2.4 + - mypy - pip: - burocrata diff --git a/pooch/core.py b/pooch/core.py index 5b294522..6470418c 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -14,7 +14,6 @@ import shlex import shutil import typing as t -import typing_extensions as te from .hashes import hash_matches, file_hash @@ -30,10 +29,10 @@ from .downloaders import DOIDownloader, choose_downloader, doi_to_repository FilePath = t.Union[str, os.PathLike] -Actions = te.Literal["download", "fetch", "update"] +Actions = t.Literal["download", "fetch", "update"] -class Downloader(te.Protocol): +class Downloader(t.Protocol): """ A class used to define the type definition for the downloader function. """ diff --git a/pyproject.toml b/pyproject.toml index a71edacc..de10e2b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ dependencies = [ "platformdirs >= 2.5.0", "packaging >= 20.0", "requests >= 2.19.0", - "typing_extensions >= 4.0.0", ] [[tool.mypy.overrides]] From 09874ed7245199d077feb590b328cc72a9ee30c4 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 21:53:49 -0600 Subject: [PATCH 13/27] Update requirements-style.txt --- env/requirements-style.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/env/requirements-style.txt b/env/requirements-style.txt index d8da6ccb..15f55e7f 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -8,3 +8,4 @@ types-requests types-tqdm types-paramiko mypy +pytest From 524a365b347ae6cf08e0bedef6ee8f016c87407d Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 21:57:13 -0600 Subject: [PATCH 14/27] Change import style --- pooch/core.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 6470418c..3629c3be 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -7,13 +7,14 @@ """ The main Pooch class and a factory function for it. """ + import os import time import contextlib from pathlib import Path import shlex import shutil -import typing as t +from typing import Union, Literal, Protocol, Optional, Any, Callable from .hashes import hash_matches, file_hash @@ -28,11 +29,11 @@ ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository -FilePath = t.Union[str, os.PathLike] -Actions = t.Literal["download", "fetch", "update"] +FilePath = Union[str, os.PathLike] +Actions = Literal["download", "fetch", "update"] -class Downloader(t.Protocol): +class Downloader(Protocol): """ A class used to define the type definition for the downloader function. """ @@ -41,14 +42,14 @@ class Downloader(t.Protocol): def __call__( # noqa: E704 self, fname: str, - action: t.Optional[FilePath], + action: Optional[FilePath], pooch: "Pooch", *, - check_only: t.Optional[bool] = None, - ) -> t.Any: ... + check_only: Optional[bool] = None, + ) -> Any: ... -Processor = t.Callable[[str, Actions, "Pooch"], t.Any] +Processor = Callable[[str, Actions, "Pooch"], Any] def retrieve( @@ -504,8 +505,8 @@ def __init__( self, path: str, base_url: str, - registry: t.Optional[t.Dict[str, str]] = None, - urls: t.Optional[t.Dict[str, str]] = None, + registry: Optional[dict[str, str]] = None, + urls: Optional[dict[str, str]] = None, retry_if_failed: int = 0, allow_updates: bool = True, ) -> None: @@ -526,15 +527,15 @@ def abspath(self) -> Path: return Path(os.path.abspath(os.path.expanduser(str(self.path)))) @property - def registry_files(self) -> t.List[str]: + def registry_files(self) -> list[str]: "List of file names on the registry" return list(self.registry) def fetch( self, fname: str, - processor: t.Optional[Processor] = None, - downloader: t.Optional[Downloader] = None, + processor: Optional[Processor] = None, + downloader: Optional[Downloader] = None, progressbar: bool = False, ) -> str: """ @@ -673,7 +674,7 @@ def load_registry(self, fname: FilePath) -> None: with contextlib.ExitStack() as stack: if hasattr(fname, "read"): # It's a file object - fin: t.Any = fname + fin: Any = fname else: # It's a file path fin = stack.enter_context(open(fname, encoding="utf-8")) @@ -732,7 +733,7 @@ def load_registry_from_doi(self) -> None: # Call registry population for this repository return repository.populate_registry(self) - def is_available(self, fname: str, downloader: t.Optional[Downloader] = None): + def is_available(self, fname: str, downloader: Optional[Downloader] = None): """ Check availability of a remote file without downloading it. From 80bcb4f062d996ed56fc395f8bdb7758008aee40 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 22:09:30 -0600 Subject: [PATCH 15/27] Add some more type hints --- pooch/core.py | 41 +++++++++++++++++++++-------------------- pooch/utils.py | 10 +++++++++- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 3629c3be..3141f80f 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -26,10 +26,11 @@ temporary_file, os_cache, unique_file_name, + FilePath, + FilePathInput, ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository -FilePath = Union[str, os.PathLike] Actions = Literal["download", "fetch", "update"] @@ -49,18 +50,18 @@ def __call__( # noqa: E704 ) -> Any: ... -Processor = Callable[[str, Actions, "Pooch"], Any] +Processor = Callable[[str, Actions, Optional["Pooch"]], Any] def retrieve( - url, - known_hash, - fname=None, - path=None, - processor=None, - downloader=None, - progressbar=False, -): + url: str, + known_hash: Optional[str] = None, + fname: Optional[str] = None, + path: Optional[FilePath] = None, + processor: Optional[Processor] = None, + downloader: Optional[Downloader] = None, + progressbar: bool = False, +) -> str: """ Download and cache a single file locally. @@ -278,15 +279,15 @@ def retrieve( def create( - path, - base_url, - version=None, - version_dev="master", - env=None, - registry=None, - urls=None, - retry_if_failed=0, - allow_updates=True, + path: FilePathInput, + base_url: str, + version: Optional[str] = None, + version_dev: str = "master", + env: Optional[str] = None, + registry: Optional[dict] = None, + urls: Optional[dict] = None, + retry_if_failed: int = 0, + allow_updates: Union[bool, str] = True, ): """ Create a :class:`~pooch.Pooch` with sensible defaults to fetch data files. @@ -503,7 +504,7 @@ class Pooch: def __init__( self, - path: str, + path: FilePath, base_url: str, registry: Optional[dict[str, str]] = None, urls: Optional[dict[str, str]] = None, diff --git a/pooch/utils.py b/pooch/utils.py index fb88dab7..70bbb2d5 100644 --- a/pooch/utils.py +++ b/pooch/utils.py @@ -7,6 +7,7 @@ """ Misc utilities """ + import logging import os import tempfile @@ -198,7 +199,14 @@ def parse_url(url): return {"protocol": protocol, "netloc": netloc, "path": path} -def cache_location(path, env=None, version=None): +from typing import Optional, Union + +FilePath = Union[str, os.PathLike] +FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] + +def cache_location( + path: FilePathInput, env: Optional[str] = None, version: Optional[str] = None +) -> Path: """ Location of the cache given a base path and optional configuration. From 8a4ea6204a6577c31f1074ce7e4b92e21892d9d5 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 22:12:31 -0600 Subject: [PATCH 16/27] Update core.py --- pooch/core.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 3141f80f..617afbdb 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -771,7 +771,7 @@ def is_available(self, fname: str, downloader: Optional[Downloader] = None): return available -def download_action(path, known_hash): +def download_action(path: Path, known_hash: Optional[str]) -> tuple[Actions, str]: """ Determine the action that is needed to get the file on disk. @@ -798,15 +798,11 @@ def download_action(path, known_hash): """ if not path.exists(): - action = "download" - verb = "Downloading" + return "download", "Downloading" elif not hash_matches(str(path), known_hash): - action = "update" - verb = "Updating" - else: - action = "fetch" - verb = "Fetching" - return action, verb + return "update", "Updating" + + return "fetch", "Fetching" def stream_download(url, fname, known_hash, downloader, pooch=None, retry_if_failed=0): From d12ec2a084738b18fa9247dede00ca2bdc4c7f0a Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 22:15:56 -0600 Subject: [PATCH 17/27] Update core.py --- pooch/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 617afbdb..228909a8 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -44,7 +44,7 @@ def __call__( # noqa: E704 self, fname: str, action: Optional[FilePath], - pooch: "Pooch", + pooch: Optional["Pooch"], *, check_only: Optional[bool] = None, ) -> Any: ... @@ -805,7 +805,14 @@ def download_action(path: Path, known_hash: Optional[str]) -> tuple[Actions, str return "fetch", "Fetching" -def stream_download(url, fname, known_hash, downloader, pooch=None, retry_if_failed=0): +def stream_download( + url: str, + fname: Path, + known_hash: Optional[str], + downloader: Downloader, + pooch: Optional[Pooch] = None, + retry_if_failed: int = 0, +) -> None: """ Stream the file and check that its hash matches the known one. From 0f85eb00a260e07e34e163618cb0f7d74bbecc07 Mon Sep 17 00:00:00 2001 From: Eliot Robson Date: Fri, 24 Jan 2025 22:26:20 -0600 Subject: [PATCH 18/27] Update utils.py --- pooch/utils.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/pooch/utils.py b/pooch/utils.py index 70bbb2d5..d1937975 100644 --- a/pooch/utils.py +++ b/pooch/utils.py @@ -20,12 +20,24 @@ import platformdirs from packaging.version import Version +from typing import Optional, Union, Any, TypedDict, Generator + + +class ParsedURL(TypedDict): + protocol: str + netloc: str + path: str + + +FilePath = Union[str, os.PathLike] +FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] + LOGGER = logging.Logger("pooch") LOGGER.addHandler(logging.StreamHandler()) -def file_hash(*args, **kwargs): +def file_hash(*args, **kwargs) -> Any: """ WARNING: Importing this function from pooch.utils is DEPRECATED. Please import from the top-level namespace (`from pooch import file_hash`) @@ -55,7 +67,7 @@ def file_hash(*args, **kwargs): return new_file_hash(*args, **kwargs) -def get_logger(): +def get_logger() -> logging.Logger: r""" Get the default event logger. @@ -71,7 +83,7 @@ def get_logger(): return LOGGER -def os_cache(project): +def os_cache(project: str) -> Path: r""" Default cache location based on the operating system. @@ -100,7 +112,7 @@ def os_cache(project): return Path(platformdirs.user_cache_dir(project)) -def check_version(version, fallback="master"): +def check_version(version: str, fallback: str = "master") -> str: """ Check if a version is PEP440 compliant and there are no unreleased changes. @@ -146,7 +158,7 @@ def check_version(version, fallback="master"): return version -def parse_url(url): +def parse_url(url: str) -> ParsedURL: """ Parse a URL into 3 components: @@ -199,11 +211,6 @@ def parse_url(url): return {"protocol": protocol, "netloc": netloc, "path": path} -from typing import Optional, Union - -FilePath = Union[str, os.PathLike] -FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] - def cache_location( path: FilePathInput, env: Optional[str] = None, version: Optional[str] = None ) -> Path: @@ -243,7 +250,7 @@ def cache_location( return Path(path) -def make_local_storage(path, env=None): +def make_local_storage(path: FilePath, env: Optional[str] = None) -> None: """ Create the local cache directory and make sure it's writable. @@ -285,7 +292,7 @@ def make_local_storage(path, env=None): @contextmanager -def temporary_file(path=None): +def temporary_file(path: Optional[FilePath] = None) -> Generator[str, None, None]: """ Create a closed and named temporary file and make sure it's cleaned up. @@ -305,7 +312,7 @@ def temporary_file(path=None): The path to the temporary file. """ - tmp = tempfile.NamedTemporaryFile(delete=False, dir=path) + tmp = tempfile.NamedTemporaryFile(delete=False, dir=path) # type: ignore # Close the temp file so that it can be opened elsewhere tmp.close() try: @@ -315,7 +322,7 @@ def temporary_file(path=None): os.remove(tmp.name) -def unique_file_name(url): +def unique_file_name(url: str) -> str: """ Create a unique file name based on the given URL. From cd30d81b4fdcfa85416e7eb01bb6a989c506d789 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 10:55:38 -0800 Subject: [PATCH 19/27] Move new type classes to their own typing module --- pooch/core.py | 26 +------------ pooch/typing/__init__.py | 82 ++++++++++++++++++++++++++++++++++++++++ pooch/utils.py | 13 +------ 3 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 pooch/typing/__init__.py diff --git a/pooch/core.py b/pooch/core.py index 228909a8..2b8eb1ab 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -14,7 +14,7 @@ from pathlib import Path import shlex import shutil -from typing import Union, Literal, Protocol, Optional, Any, Callable +from typing import Union, Optional, Any from .hashes import hash_matches, file_hash @@ -26,31 +26,9 @@ temporary_file, os_cache, unique_file_name, - FilePath, - FilePathInput, ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository - -Actions = Literal["download", "fetch", "update"] - - -class Downloader(Protocol): - """ - A class used to define the type definition for the downloader function. - """ - - # pylint: disable=too-few-public-methods - def __call__( # noqa: E704 - self, - fname: str, - action: Optional[FilePath], - pooch: Optional["Pooch"], - *, - check_only: Optional[bool] = None, - ) -> Any: ... - - -Processor = Callable[[str, Actions, Optional["Pooch"]], Any] +from .typing import FilePath, FilePathInput, Processor, Downloader, Actions def retrieve( diff --git a/pooch/typing/__init__.py b/pooch/typing/__init__.py new file mode 100644 index 00000000..36618e17 --- /dev/null +++ b/pooch/typing/__init__.py @@ -0,0 +1,82 @@ +# Copyright (c) 2018 The Pooch Developers. +# Distributed under the terms of the BSD 3-Clause License. +# SPDX-License-Identifier: BSD-3-Clause +# +# This code is part of the Fatiando a Terra project (https://www.fatiando.org) +# +""" +============================= +Typing (:mod:`pooch.typing`) +============================= + +This module provides additional `PEP 484 `_ +type aliases used in ``pooch``'s codebase. + +API +--- + +.. autosummary:: + :toctree: generated/ + + Actions + Downloader + FilePath + FilePathInput + ParsedURL + Processor + +""" + +import os +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Literal, + Optional, + Protocol, + TypedDict, + Union, +) + +# Import Pooch only if TYPE_CHECKING is true to avoid circular loops at runtime +if TYPE_CHECKING: + from .. import Pooch + + +__all__ = [ + "Actions", + "Downloader", + "FilePath", + "FilePathInput", + "ParsedURL", + "Processor", +] + + +Actions = Literal["download", "fetch", "update"] +FilePath = Union[str, os.PathLike] +FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] +Processor = Callable[[str, Actions, Optional["Pooch"]], Any] + + +class Downloader(Protocol): + """ + A class used to define the type definition for the downloader function. + """ + + # pylint: disable=too-few-public-methods + def __call__( # noqa: E704 + self, + fname: str, + action: Optional[FilePath], + pooch: Optional["Pooch"], + *, + check_only: Optional[bool] = None, + ) -> Any: ... + + +class ParsedURL(TypedDict): + protocol: str + netloc: str + path: str diff --git a/pooch/utils.py b/pooch/utils.py index d1937975..c4c3a7c1 100644 --- a/pooch/utils.py +++ b/pooch/utils.py @@ -19,18 +19,9 @@ import platformdirs from packaging.version import Version +from typing import Optional, Any, Generator -from typing import Optional, Union, Any, TypedDict, Generator - - -class ParsedURL(TypedDict): - protocol: str - netloc: str - path: str - - -FilePath = Union[str, os.PathLike] -FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] +from .typing import ParsedURL, FilePath, FilePathInput LOGGER = logging.Logger("pooch") From 7d9faed06ecc86245e7c1bb00a48028316f7ae60 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 10:56:48 -0800 Subject: [PATCH 20/27] Rename "Actions" for "Action" --- pooch/core.py | 4 ++-- pooch/typing/__init__.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index 2b8eb1ab..cd557b36 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -28,7 +28,7 @@ unique_file_name, ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository -from .typing import FilePath, FilePathInput, Processor, Downloader, Actions +from .typing import FilePath, FilePathInput, Processor, Downloader, Action def retrieve( @@ -749,7 +749,7 @@ def is_available(self, fname: str, downloader: Optional[Downloader] = None): return available -def download_action(path: Path, known_hash: Optional[str]) -> tuple[Actions, str]: +def download_action(path: Path, known_hash: Optional[str]) -> tuple[Action, str]: """ Determine the action that is needed to get the file on disk. diff --git a/pooch/typing/__init__.py b/pooch/typing/__init__.py index 36618e17..07b2fb70 100644 --- a/pooch/typing/__init__.py +++ b/pooch/typing/__init__.py @@ -18,7 +18,7 @@ .. autosummary:: :toctree: generated/ - Actions + Action Downloader FilePath FilePathInput @@ -45,7 +45,7 @@ __all__ = [ - "Actions", + "Action", "Downloader", "FilePath", "FilePathInput", @@ -54,10 +54,10 @@ ] -Actions = Literal["download", "fetch", "update"] +Action = Literal["download", "fetch", "update"] FilePath = Union[str, os.PathLike] FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] -Processor = Callable[[str, Actions, Optional["Pooch"]], Any] +Processor = Callable[[str, Action, Optional["Pooch"]], Any] class Downloader(Protocol): From 1f6df40bccd0e6008e2a86923af58a95268c5128 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 11:12:00 -0800 Subject: [PATCH 21/27] Add typing submodule to API Reference in docs --- doc/api/index.rst | 17 +++++++++++++++++ pooch/typing/__init__.py | 18 +----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/doc/api/index.rst b/doc/api/index.rst index a349c369..5da9ffde 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -64,3 +64,20 @@ Miscellaneous :toctree: generated/ pooch.test + +Typing +------ + +Custom classes for type annotations. +This module provides additional `PEP 484 `_ +type aliases used in ``pooch``'s codebase. + +.. autosummary:: + :toctree: generated/ + + pooch.typing.Action + pooch.typing.Downloader + pooch.typing.FilePath + pooch.typing.FilePathInput + pooch.typing.ParsedURL + pooch.typing.Processor diff --git a/pooch/typing/__init__.py b/pooch/typing/__init__.py index 07b2fb70..43e9d3e6 100644 --- a/pooch/typing/__init__.py +++ b/pooch/typing/__init__.py @@ -5,26 +5,10 @@ # This code is part of the Fatiando a Terra project (https://www.fatiando.org) # """ -============================= -Typing (:mod:`pooch.typing`) -============================= +Custom classes for type annotations This module provides additional `PEP 484 `_ type aliases used in ``pooch``'s codebase. - -API ---- - -.. autosummary:: - :toctree: generated/ - - Action - Downloader - FilePath - FilePathInput - ParsedURL - Processor - """ import os From 9e7201566eb65f1917d598e0cc03e96039a4df24 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 11:14:04 -0800 Subject: [PATCH 22/27] Rename FilePath and FilePathInput types Rename them to `PathType` and `PathInputType` since those paths are not usually used for files, but for directories as well. --- doc/api/index.rst | 4 ++-- pooch/core.py | 10 +++++----- pooch/typing/__init__.py | 10 +++++----- pooch/utils.py | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/api/index.rst b/doc/api/index.rst index 5da9ffde..1014343b 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -77,7 +77,7 @@ type aliases used in ``pooch``'s codebase. pooch.typing.Action pooch.typing.Downloader - pooch.typing.FilePath - pooch.typing.FilePathInput + pooch.typing.PathType + pooch.typing.PathInputType pooch.typing.ParsedURL pooch.typing.Processor diff --git a/pooch/core.py b/pooch/core.py index cd557b36..e044a1ab 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -28,14 +28,14 @@ unique_file_name, ) from .downloaders import DOIDownloader, choose_downloader, doi_to_repository -from .typing import FilePath, FilePathInput, Processor, Downloader, Action +from .typing import PathType, PathInputType, Processor, Downloader, Action def retrieve( url: str, known_hash: Optional[str] = None, fname: Optional[str] = None, - path: Optional[FilePath] = None, + path: Optional[PathType] = None, processor: Optional[Processor] = None, downloader: Optional[Downloader] = None, progressbar: bool = False, @@ -257,7 +257,7 @@ def retrieve( def create( - path: FilePathInput, + path: PathInputType, base_url: str, version: Optional[str] = None, version_dev: str = "master", @@ -482,7 +482,7 @@ class Pooch: def __init__( self, - path: FilePath, + path: PathType, base_url: str, registry: Optional[dict[str, str]] = None, urls: Optional[dict[str, str]] = None, @@ -631,7 +631,7 @@ def get_url(self, fname: str) -> str: self._assert_file_in_registry(fname) return self.urls.get(fname, "".join([self.base_url, fname])) - def load_registry(self, fname: FilePath) -> None: + def load_registry(self, fname: PathType) -> None: """ Load entries from a file and add them to the registry. diff --git a/pooch/typing/__init__.py b/pooch/typing/__init__.py index 43e9d3e6..6e85455e 100644 --- a/pooch/typing/__init__.py +++ b/pooch/typing/__init__.py @@ -31,16 +31,16 @@ __all__ = [ "Action", "Downloader", - "FilePath", - "FilePathInput", + "PathType", + "PathInputType", "ParsedURL", "Processor", ] Action = Literal["download", "fetch", "update"] -FilePath = Union[str, os.PathLike] -FilePathInput = Union[FilePath, list[FilePath], tuple[FilePath]] +PathType = Union[str, os.PathLike] +PathInputType = Union[PathType, list[PathType], tuple[PathType]] Processor = Callable[[str, Action, Optional["Pooch"]], Any] @@ -53,7 +53,7 @@ class Downloader(Protocol): def __call__( # noqa: E704 self, fname: str, - action: Optional[FilePath], + action: Optional[PathType], pooch: Optional["Pooch"], *, check_only: Optional[bool] = None, diff --git a/pooch/utils.py b/pooch/utils.py index c4c3a7c1..152af514 100644 --- a/pooch/utils.py +++ b/pooch/utils.py @@ -21,7 +21,7 @@ from packaging.version import Version from typing import Optional, Any, Generator -from .typing import ParsedURL, FilePath, FilePathInput +from .typing import ParsedURL, PathType, PathInputType LOGGER = logging.Logger("pooch") @@ -203,7 +203,7 @@ def parse_url(url: str) -> ParsedURL: def cache_location( - path: FilePathInput, env: Optional[str] = None, version: Optional[str] = None + path: PathInputType, env: Optional[str] = None, version: Optional[str] = None ) -> Path: """ Location of the cache given a base path and optional configuration. @@ -241,7 +241,7 @@ def cache_location( return Path(path) -def make_local_storage(path: FilePath, env: Optional[str] = None) -> None: +def make_local_storage(path: PathType, env: Optional[str] = None) -> None: """ Create the local cache directory and make sure it's writable. @@ -283,7 +283,7 @@ def make_local_storage(path: FilePath, env: Optional[str] = None) -> None: @contextmanager -def temporary_file(path: Optional[FilePath] = None) -> Generator[str, None, None]: +def temporary_file(path: Optional[PathType] = None) -> Generator[str, None, None]: """ Create a closed and named temporary file and make sure it's cleaned up. From 1595a9eb2bfda8e561ade18e5d5a81a08fce0d5b Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 11:22:18 -0800 Subject: [PATCH 23/27] Minor improvements to docstrings --- pooch/typing/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pooch/typing/__init__.py b/pooch/typing/__init__.py index 6e85455e..c683490c 100644 --- a/pooch/typing/__init__.py +++ b/pooch/typing/__init__.py @@ -46,7 +46,7 @@ class Downloader(Protocol): """ - A class used to define the type definition for the downloader function. + Class used to define the type definition for the downloader function. """ # pylint: disable=too-few-public-methods @@ -61,6 +61,12 @@ def __call__( # noqa: E704 class ParsedURL(TypedDict): + """ + Type for a dictionary generated after parsing a URL. + + The dictionary contains three keys: protocol, netloc and path. + """ + protocol: str netloc: str path: str From 17906dc6087ea70b012cce29e62901543c45097b Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 14:55:12 -0800 Subject: [PATCH 24/27] Fix import order in pooch/utils.py --- pooch/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pooch/utils.py b/pooch/utils.py index 152af514..c0c74a42 100644 --- a/pooch/utils.py +++ b/pooch/utils.py @@ -16,10 +16,10 @@ from urllib.parse import urlsplit from contextlib import contextmanager import warnings +from typing import Optional, Any, Generator import platformdirs from packaging.version import Version -from typing import Optional, Any, Generator from .typing import ParsedURL, PathType, PathInputType From a033335fecd92c182d47b41ba1169ac68371301f Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 14:59:57 -0800 Subject: [PATCH 25/27] Fix pylint complain: no need for elif after return --- pooch/core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pooch/core.py b/pooch/core.py index e044a1ab..97aea3fb 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -777,9 +777,8 @@ def download_action(path: Path, known_hash: Optional[str]) -> tuple[Action, str] """ if not path.exists(): return "download", "Downloading" - elif not hash_matches(str(path), known_hash): + if not hash_matches(str(path), known_hash): return "update", "Updating" - return "fetch", "Fetching" From b4b6b6af9c36a7059ade863fd0f14195a6a48e8c Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Tue, 18 Feb 2025 15:01:03 -0800 Subject: [PATCH 26/27] Add extra requirements for type checks to environment.yml --- env/requirements-style.txt | 2 +- environment.yml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/env/requirements-style.txt b/env/requirements-style.txt index 15f55e7f..05584578 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -1,4 +1,4 @@ -# Style checks +# Style and type checks black flake8 pylint>=2.4 diff --git a/environment.yml b/environment.yml index fbba4eaf..b2b16578 100644 --- a/environment.yml +++ b/environment.yml @@ -26,11 +26,14 @@ dependencies: - sphinx==7.2.* - sphinx-book-theme==1.1.* - sphinx-design==0.5.* - # Style + # Style and types - pathspec - black>=20.8b1 - flake8 - pylint>=2.4 - mypy + - types-requests + - types-tqdm + - types-paramiko - pip: - burocrata From 89c3363e1cc440587d1e764567ecc20138531d0b Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 24 Feb 2025 10:27:54 -0800 Subject: [PATCH 27/27] Use list instead of the deprecated List Replace `typing.List` for the builtin `list`, since the former has been deprecated. --- doc/conf.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 1370d142..c862308d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -8,7 +8,6 @@ import datetime import pooch -import typing as t # Project information @@ -45,7 +44,7 @@ } # Autosummary pages will be generated by sphinx-autogen instead of sphinx-build -autosummary_generate: t.List = [] +autosummary_generate: list = [] # Otherwise, the Return parameter list looks different from the Parameters list napoleon_use_rtype = False @@ -78,7 +77,7 @@ html_static_path = ["_static"] # CSS files are relative to the static path html_css_files = ["style.css"] -html_extra_path: t.List = [] +html_extra_path: list = [] html_show_sourcelink = False html_show_sphinx = True html_show_copyright = True