Skip to content
Snippets Groups Projects
Commit 5ad4fd33 authored by Stefano Zacchiroli's avatar Stefano Zacchiroli
Browse files

typing: minimal changes to make a no-op mypy run pass

parent 8faa3254
No related branches found
No related tags found
No related merge requests found
......@@ -11,3 +11,4 @@ swh.core.egg-info
version.txt
.tox
.hypothesis
.mypy_cache/
mypy.ini 0 → 100644
[mypy]
namespace_packages = True
warn_unused_ignores = True
# 3rd party libraries without stubs (yet)
[mypy-aiohttp_utils.*]
ignore_missing_imports = True
[mypy-arrow.*]
ignore_missing_imports = True
[mypy-celery.*]
ignore_missing_imports = True
[mypy-decorator.*]
ignore_missing_imports = True
[mypy-deprecated.*]
ignore_missing_imports = True
[mypy-msgpack.*]
ignore_missing_imports = True
[mypy-pkg_resources.*]
ignore_missing_imports = True
[mypy-psycopg2.*]
ignore_missing_imports = True
[mypy-pytest.*]
ignore_missing_imports = True
[mypy-systemd.*]
ignore_missing_imports = True
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
from typing import Iterable
__path__ = __import__('pkgutil').extend_path(__path__,
__name__) # type: Iterable[str]
......@@ -12,6 +12,8 @@ import pickle
import requests
import datetime
from typing import ClassVar, Optional, Type
from deprecated import deprecated
from flask import Flask, Request, Response, request, abort
from .serializers import (decode_response,
......@@ -140,7 +142,7 @@ class RPCClient(metaclass=MetaRPCClient):
"""
backend_class = None
backend_class = None # type: ClassVar[Optional[type]]
"""For each method of `backend_class` decorated with
:func:`remote_api_endpoint`, a method with the same prototype and
docstring will be added to this class. Calls to this new method will
......@@ -149,7 +151,7 @@ class RPCClient(metaclass=MetaRPCClient):
This backend class will never be instantiated, it only serves as
a template."""
api_exception = APIError
api_exception = APIError # type: ClassVar[Type[Exception]]
"""The exception class to raise in case of communication error with
the server."""
......
......@@ -24,9 +24,10 @@
#
from collections import defaultdict
from decorator import decorator
from inspect import getcallargs
from decorator import decorator
from typing import Any, List, Optional
class FormatterNotFound(Exception):
......@@ -34,8 +35,8 @@ class FormatterNotFound(Exception):
class Formatter:
format = None
mimetypes = []
format = None # type: Optional[str]
mimetypes = [] # type: List[Any]
def __init__(self, request_mimetype=None):
if request_mimetype is None or request_mimetype not in self.mimetypes:
......
......@@ -5,7 +5,7 @@
import unittest
import requests_mock
import requests_mock # type: ignore
from werkzeug.wrappers import BaseResponse
from werkzeug.test import Client as WerkzeugTestClient
......
......@@ -4,9 +4,8 @@
# See top-level LICENSE file for more information
import datetime
import json
import msgpack
import json
import pytest
......
......@@ -10,6 +10,8 @@ import yaml
from itertools import chain
from copy import deepcopy
from typing import Any, Dict, Optional, Tuple
logger = logging.getLogger(__name__)
......@@ -311,8 +313,8 @@ class SWHConfig:
"""
DEFAULT_CONFIG = {}
CONFIG_BASE_FILENAME = ''
DEFAULT_CONFIG = {} # type: Dict[str, Tuple[str, Any]]
CONFIG_BASE_FILENAME = '' # type: Optional[str]
@classmethod
def parse_config_file(cls, base_filename=None, config_filename=None,
......
......@@ -9,9 +9,12 @@ import subprocess
import psycopg2
from typing import Dict, Iterable, Optional, Tuple, Union
from swh.core.utils import numfile_sortkey as sortkey
DB_DUMP_TYPES = {'.sql': 'psql', '.dump': 'pg_dump'}
DB_DUMP_TYPES = {'.sql': 'psql', '.dump': 'pg_dump'} # type: Dict[str, str]
def swh_db_version(dbname_or_service):
......@@ -207,8 +210,8 @@ class DbTestFixture:
"""
_DB_DUMP_LIST = {}
_DB_LIST = {}
_DB_DUMP_LIST = {} # type: Dict[str, Iterable[Tuple[str, str]]]
_DB_LIST = {} # type: Dict[str, DbTestContext]
DB_TEST_FIXTURE_IMPORTED = True
@classmethod
......@@ -286,7 +289,7 @@ class SingleDbTestFixture(DbTestFixture):
"""
TEST_DB_NAME = 'softwareheritage-test'
TEST_DB_DUMP = None
TEST_DB_DUMP = None # type: Optional[Union[str, Iterable[str]]]
@classmethod
def setUpClass(cls):
......
# Marker file for PEP 561.
[tox]
envlist=flake8,py3-{core,db,server}
envlist=flake8,py3-{core,db,server},mypy
[testenv:py3-core]
deps =
......@@ -42,3 +42,12 @@ deps =
flake8
commands =
{envpython} -m flake8
[testenv:mypy]
skip_install = true
deps =
.[testing]
mypy
django-stubs
commands =
mypy swh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment