Skip to content

Commit 77100b0

Browse files
committed
Fix linter warnings
1 parent b25fe73 commit 77100b0

File tree

8 files changed

+25
-24
lines changed

8 files changed

+25
-24
lines changed

app/router/v1/confirmed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
@V1.get("/confirmed")
77
async def confirmed():
88
"""Confirmed cases."""
9-
confirmed = await get_category("confirmed")
9+
confirmed_data = await get_category("confirmed")
1010

11-
return confirmed
11+
return confirmed_data

app/router/v1/deaths.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
@V1.get("/deaths")
77
async def deaths():
88
"""Total deaths."""
9-
deaths = await get_category("deaths")
9+
deaths_data = await get_category("deaths")
1010

11-
return deaths
11+
return deaths_data

app/router/v1/recovered.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
@V1.get("/recovered")
77
async def recovered():
88
"""Recovered cases."""
9-
recovered = await get_category("recovered")
9+
recovered_data = await get_category("recovered")
1010

11-
return recovered
11+
return recovered_data

app/services/location/csbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def get_locations():
3939
:returns: The locations.
4040
:rtype: dict
4141
"""
42-
async with httputils.client_session.get(BASE_URL) as response:
42+
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
4343
text = await response.text()
4444

4545
data = list(csv.DictReader(text.splitlines()))

app/services/location/jhu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def get_category(category):
5555
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
5656

5757
# Request the data
58-
async with httputils.client_session.get(url) as response:
58+
async with httputils.CLIENT_SESSION.get(url) as response:
5959
text = await response.text()
6060

6161
# Parse the CSV.

app/utils/httputils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
"""app.utils.httputils.py"""
12
import logging
23

34
from aiohttp import ClientSession
45

56

67
# Singleton aiohttp.ClientSession instance.
7-
client_session: ClientSession
8+
CLIENT_SESSION: ClientSession
89

910

1011
LOGGER = logging.getLogger(__name__)
@@ -17,14 +18,14 @@ async def setup_client_session():
1718
See: https://docs.aiohttp.org/en/stable/client_quickstart.html#make-a-request
1819
1920
"""
20-
global client_session
21+
global CLIENT_SESSION # pylint: disable=global-statement
2122
LOGGER.info("Setting up global aiohttp.ClientSession.")
22-
client_session = ClientSession()
23+
CLIENT_SESSION = ClientSession()
2324

2425

2526
async def teardown_client_session():
2627
"""Close the application-global aiohttp.ClientSession.
2728
"""
28-
global client_session
29+
global CLIENT_SESSION # pylint: disable=global-statement
2930
LOGGER.info("Closing global aiohttp.ClientSession.")
30-
await client_session.close()
31+
await CLIENT_SESSION.close()

tests/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ def mock_client_session_class(request):
8080
See: https://docs.pytest.org/en/5.4.1/unittest.html#mixing-pytest-fixtures-into-unittest-testcase-subclasses-using-marks
8181
"""
8282

83-
httputils.client_session = request.cls.mock_client_session = mock.AsyncMock()
84-
httputils.client_session.get = mocked_session_get
83+
httputils.CLIENT_SESSION = request.cls.mock_client_session = mock.AsyncMock()
84+
httputils.CLIENT_SESSION.get = mocked_session_get
8585
try:
8686
yield
8787
finally:
88-
del httputils.client_session
88+
del httputils.CLIENT_SESSION
8989

9090

9191
@pytest.fixture
@@ -94,12 +94,12 @@ async def mock_client_session():
9494
instance.
9595
"""
9696

97-
httputils.client_session = mock.AsyncMock()
98-
httputils.client_session.get = mocked_session_get
97+
httputils.CLIENT_SESSION = mock.AsyncMock()
98+
httputils.CLIENT_SESSION.get = mocked_session_get
9999
try:
100-
yield httputils.client_session
100+
yield httputils.CLIENT_SESSION
101101
finally:
102-
del httputils.client_session
102+
del httputils.CLIENT_SESSION
103103

104104

105105
@asynccontextmanager

tests/test_httputils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
async def test_setup_teardown_client_session():
88
with pytest.raises(AttributeError):
99
# Ensure client_session is undefined prior to setup
10-
httputils.client_session
10+
httputils.CLIENT_SESSION
1111

1212
await httputils.setup_client_session()
1313

14-
assert httputils.client_session
14+
assert httputils.CLIENT_SESSION
1515

1616
await httputils.teardown_client_session()
17-
assert httputils.client_session.closed
17+
assert httputils.CLIENT_SESSION.closed
1818

19-
del httputils.client_session
19+
del httputils.CLIENT_SESSION

0 commit comments

Comments
 (0)