python: Reformat code with black 22.3.0

Related to T3922
This commit is contained in:
Antoine Lambert 2022-04-08 15:15:09 +02:00
parent 00f1b99ad9
commit d38e05cff7
37 changed files with 265 additions and 144 deletions

View file

@ -8,15 +8,24 @@ import pytest
from swh.lister.cli import SUPPORTED_LISTERS, get_lister
lister_args = {
"cgit": {"url": "https://git.eclipse.org/c/",},
"cgit": {
"url": "https://git.eclipse.org/c/",
},
"phabricator": {
"instance": "softwareheritage",
"url": "https://forge.softwareheritage.org/api/diffusion.repository.search",
"api_token": "bogus",
},
"gitea": {"url": "https://try.gitea.io/api/v1/",},
"tuleap": {"url": "https://tuleap.net",},
"gitlab": {"url": "https://gitlab.ow2.org/api/v4", "instance": "ow2",},
"gitea": {
"url": "https://try.gitea.io/api/v1/",
},
"tuleap": {
"url": "https://tuleap.net",
},
"gitlab": {
"url": "https://gitlab.ow2.org/api/v4",
"instance": "ow2",
},
"opam": {"url": "https://opam.ocaml.org", "instance": "opam"},
"maven": {
"url": "https://repo1.maven.org/maven2/",
@ -34,9 +43,7 @@ def test_get_lister_wrong_input():
def test_get_lister(swh_scheduler_config):
"""Instantiating a supported lister should be ok
"""
"""Instantiating a supported lister should be ok"""
# Drop launchpad lister from the lister to check, its test setup is more involved
# than the other listers and it's not currently done here
for lister_name in SUPPORTED_LISTERS:

View file

@ -154,7 +154,9 @@ class InstantiableStatelessLister(pattern.StatelessLister[PageType]):
def test_stateless_instantiation(swh_scheduler):
lister = InstantiableStatelessLister(
scheduler=swh_scheduler, url="https://example.com", instance="example.com",
scheduler=swh_scheduler,
url="https://example.com",
instance="example.com",
)
# check the lister was registered in the scheduler backend

View file

@ -21,7 +21,19 @@ from swh.lister.utils import (
(14, 5, [(0, 4), (5, 9), (10, 14)]),
(19, 10, [(0, 9), (10, 19)]),
(20, 3, [(0, 2), (3, 5), (6, 8), (9, 11), (12, 14), (15, 17), (18, 20)]),
(21, 3, [(0, 2), (3, 5), (6, 8), (9, 11), (12, 14), (15, 17), (18, 21),],),
(
21,
3,
[
(0, 2),
(3, 5),
(6, 8),
(9, 11),
(12, 14),
(15, 17),
(18, 21),
],
),
],
)
def test_split_range(total_pages, nb_pages, expected_ranges):
@ -72,7 +84,8 @@ def test_throttling_retry(requests_mock, mocker):
def test_throttling_retry_max_attemps(requests_mock, mocker):
requests_mock.get(
TEST_URL, [{"status_code": codes.too_many_requests}] * (MAX_NUMBER_ATTEMPTS),
TEST_URL,
[{"status_code": codes.too_many_requests}] * (MAX_NUMBER_ATTEMPTS),
)
mock_sleep = mocker.patch.object(make_request.retry, "sleep")
@ -85,7 +98,7 @@ def test_throttling_retry_max_attemps(requests_mock, mocker):
assert_sleep_calls(
mocker,
mock_sleep,
[float(WAIT_EXP_BASE ** i) for i in range(MAX_NUMBER_ATTEMPTS - 1)],
[float(WAIT_EXP_BASE**i) for i in range(MAX_NUMBER_ATTEMPTS - 1)],
)