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

This commit is contained in:
Stefano Zacchiroli 2019-10-11 15:15:09 +02:00
parent 78105940ff
commit 974f80f966
18 changed files with 135 additions and 47 deletions

View file

@ -7,6 +7,7 @@ import logging
import iso8601
from datetime import datetime, timezone
from typing import Any
from urllib import parse
from swh.lister.bitbucket.models import BitBucketModel
@ -22,7 +23,7 @@ class BitBucketLister(IndexingHttpLister):
LISTER_NAME = 'bitbucket'
DEFAULT_URL = 'https://api.bitbucket.org/2.0'
instance = 'bitbucket'
default_min_bound = datetime.fromtimestamp(0, timezone.utc)
default_min_bound = datetime.fromtimestamp(0, timezone.utc) # type: Any
def __init__(self, url=None, override_config=None, per_page=100):
super().__init__(url=url, override_config=override_config)

View file

@ -7,7 +7,6 @@ import re
import unittest
from datetime import timedelta
from urllib.parse import unquote
import iso8601
@ -17,7 +16,7 @@ from swh.lister.bitbucket.lister import BitBucketLister
from swh.lister.core.tests.test_lister import HttpListerTester
def convert_type(req_index):
def _convert_type(req_index):
"""Convert the req_index to its right type according to the model's
"indexable" column.
@ -31,17 +30,17 @@ class BitBucketListerTester(HttpListerTester, unittest.TestCase):
lister_subdir = 'bitbucket'
good_api_response_file = 'data/https_api.bitbucket.org/response.json'
bad_api_response_file = 'data/https_api.bitbucket.org/empty_response.json'
first_index = convert_type('2008-07-12T07:44:01.476818+00:00')
last_index = convert_type('2008-07-19T06:16:43.044743+00:00')
first_index = _convert_type('2008-07-12T07:44:01.476818+00:00')
last_index = _convert_type('2008-07-19T06:16:43.044743+00:00')
entries_per_page = 10
convert_type = staticmethod(convert_type)
convert_type = _convert_type
def request_index(self, request):
"""(Override) This is needed to emulate the listing bootstrap
when no min_bound is provided to run
"""
m = self.test_re.search(request.path_url)
idx = convert_type(m.group(1))
idx = _convert_type(m.group(1))
if idx == self.Lister.default_min_bound:
idx = self.first_index
return idx