Skip to content

Commit 8294d52

Browse files
authored
small fixes to coverage, type hints, documentation, and QoL for Makefile (#1101)
1 parent e8a3b8e commit 8294d52

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

CONTRIBUTING.rst

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ For example, using *virtualenvwrapper* commands could look like::
2222

2323
After that, please install libraries required for development::
2424

25+
$ pip install pip-tools
2526
$ pip-compile requirements-dev.in
2627
$ pip-sync requirements-dev.txt
2728

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Some simple testing tasks (sorry, UNIX only).
22

3-
FLAGS=
3+
# ?= conditional assign, so users can pass options on the CLI instead of manually editing this file
4+
FLAGS?=
45

56
pre-commit flake: checkrst
67
pre-commit run --all
@@ -22,7 +23,7 @@ cov cover coverage: pre-commit
2223
mototest:
2324
docker pull alpine
2425
docker pull lambci/lambda:python3.8
25-
BOTO_CONFIG=/dev/null python -Wd -X tracemalloc=5 -X faulthandler -m pytest -vv -m moto -n auto --cov-report term --cov-report html --cov-report xml --cov=aiobotocore --cov=tests --log-cli-level=DEBUG aiobotocore tests
26+
BOTO_CONFIG=/dev/null python -Wd -X tracemalloc=5 -X faulthandler -m pytest -vv -m moto -n auto --cov-report term --cov-report html --cov-report xml --cov=aiobotocore --cov=tests --log-cli-level=DEBUG $(FLAGS) aiobotocore tests
2627
@echo "open file://`pwd`/htmlcov/index.html"
2728

2829
clean:

README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ secret accessible via environment variables:
167167
::
168168

169169
$ pip install pip-tools
170-
$ pip-compile requirements-dev.txt
170+
$ pip-compile requirements-dev.in
171171
$ pip-sync requirements-dev.txt
172172
$ export AWS_ACCESS_KEY_ID=xxx
173173
$ export AWS_SECRET_ACCESS_KEY=xxx
174+
$ export AWS_DEFAULT_REGION=xxx # e.g. us-west-2
174175

175176
Execute tests suite:
176177

pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ src_paths = ["aiobotocore", "tests"]
1616
[tool.black]
1717
line-length = 79
1818
skip_string_normalization = true
19+
20+
[tool.coverage.report]
21+
exclude_also = [
22+
"if TYPE_CHECKING",
23+
]

tests/boto_tests/test_utils.py

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import annotations
2+
13
import itertools
24
import json
3-
from typing import List, Tuple, Union
5+
from typing import Iterator, Tuple, Union
46

57
import pytest
68
from botocore.exceptions import ReadTimeoutError
@@ -9,18 +11,17 @@
911
from aiobotocore import utils
1012
from aiobotocore._helpers import asynccontextmanager
1113

14+
# TypeAlias (requires typing_extensions or >=3.10 to annotate)
15+
Response = Tuple[Union[str, object], int]
16+
1217

1318
# From class TestContainerMetadataFetcher
14-
def fake_aiohttp_session(
15-
responses: Union[
16-
List[Tuple[Union[str, object], int]], Tuple[Union[str, object], int]
17-
]
18-
):
19+
def fake_aiohttp_session(responses: list[Response] | Response):
1920
"""
2021
Dodgy shim class
2122
"""
22-
if isinstance(responses, Tuple):
23-
data = itertools.cycle([responses])
23+
if isinstance(responses, tuple):
24+
data: Iterator[Response] = itertools.cycle([responses])
2425
else:
2526
data = iter(responses)
2627

@@ -83,9 +84,7 @@ async def test_idmsfetcher_disabled():
8384
@pytest.mark.asyncio
8485
async def test_idmsfetcher_get_token_success():
8586
session = fake_aiohttp_session(
86-
[
87-
('blah', 200),
88-
]
87+
('blah', 200),
8988
)
9089

9190
fetcher = utils.AioIMDSFetcher(
@@ -99,9 +98,7 @@ async def test_idmsfetcher_get_token_success():
9998
@pytest.mark.asyncio
10099
async def test_idmsfetcher_get_token_not_found():
101100
session = fake_aiohttp_session(
102-
[
103-
('blah', 404),
104-
]
101+
('blah', 404),
105102
)
106103

107104
fetcher = utils.AioIMDSFetcher(
@@ -115,9 +112,7 @@ async def test_idmsfetcher_get_token_not_found():
115112
@pytest.mark.asyncio
116113
async def test_idmsfetcher_get_token_bad_request():
117114
session = fake_aiohttp_session(
118-
[
119-
('blah', 400),
120-
]
115+
('blah', 400),
121116
)
122117

123118
fetcher = utils.AioIMDSFetcher(

0 commit comments

Comments
 (0)