From 6159faa2f5af2c9b07c503bfff5fe9a357b06be2 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 18 Oct 2019 17:32:03 +0200 Subject: [PATCH] mypy: add typing annotations for novel lister abstractions --- swh/lister/core/simple_lister.py | 5 +++-- swh/lister/cran/lister.py | 2 +- swh/lister/debian/__init__.py | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/swh/lister/core/simple_lister.py b/swh/lister/core/simple_lister.py index c63fd32..80e2040 100644 --- a/swh/lister/core/simple_lister.py +++ b/swh/lister/core/simple_lister.py @@ -5,8 +5,9 @@ import logging -from swh.core import utils +from typing import Any, List +from swh.core import utils from .lister_base import ListerBase @@ -20,7 +21,7 @@ class SimpleLister(ListerBase): information and stores those in db """ - def list_packages(self, *args): + def list_packages(self, response: Any) -> List[Any]: """Listing packages method. """ diff --git a/swh/lister/cran/lister.py b/swh/lister/cran/lister.py index 5c8e6a2..9edd35a 100644 --- a/swh/lister/cran/lister.py +++ b/swh/lister/cran/lister.py @@ -77,7 +77,7 @@ class CRANLister(SimpleLister): """ return None - def list_packages(self, *args) -> List[Mapping[str, str]]: + def list_packages(self, response) -> List[Mapping[str, str]]: """Runs R script which uses inbuilt API to return a json response containing data about the R packages. diff --git a/swh/lister/debian/__init__.py b/swh/lister/debian/__init__.py index 67af7b5..5601976 100644 --- a/swh/lister/debian/__init__.py +++ b/swh/lister/debian/__init__.py @@ -3,13 +3,13 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from typing import Any, Mapping, Optional +from typing import Any, List, Mapping, Optional def debian_init(db_engine, lister=None, override_conf: Optional[Mapping[str, Any]] = None, - distributions: Optional[str] = ['stretch', 'buster'], - area_names: Optional[str] = ['main', 'contrib', 'non-free']): + distributions: List[str] = ['stretch', 'buster'], + area_names: List[str] = ['main', 'contrib', 'non-free']): """Initialize the debian data model. Args: