Skip to content

Commit dfc4285

Browse files
committed
Fix mypy and suppress type checks for mocked test
1 parent cfc4731 commit dfc4285

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def mypy(session: Session) -> None:
151151
"""Type-check using mypy."""
152152
args = session.posargs or ["src", "tests", "docs/conf.py"]
153153
session.install(".")
154-
session.install("mypy", "pytest", "types-requests", "types-PyYAML")
154+
session.install("mypy", "pytest", "types-requests", "types-PyYAML", "typeguard")
155155
session.run("mypy", *args)
156156
if not session.posargs:
157157
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
@@ -161,7 +161,7 @@ def mypy(session: Session) -> None:
161161
def tests(session: Session) -> None:
162162
"""Run the test suite."""
163163
session.install(".")
164-
session.install("coverage[toml]", "pytest", "pygments")
164+
session.install("coverage[toml]", "pytest", "pygments", "typeguard")
165165
try:
166166
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
167167
finally:

poetry.lock

+9-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/stac_api_validator/validations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def is_geojson_type(maybe_type: Optional[str]) -> bool:
279279
def get_catalog(data_dict: Dict[str, Any], r_session: Session) -> Catalog:
280280
stac_io = StacIO.default()
281281
if r_session.headers and r_session.headers.get("Authorization"):
282-
stac_io.headers = {"Authorization": r_session.headers["Authorization"]}
282+
stac_io.headers = {"Authorization": str(r_session.headers["Authorization"])}
283283
catalog = Catalog.from_dict(data_dict)
284284
catalog._stac_io = stac_io
285285
return catalog
@@ -598,7 +598,7 @@ def validate_api(
598598
try:
599599
headers = {}
600600
if r_session.headers and r_session.headers.get("Authorization"):
601-
headers["Authorization"] = r_session.headers["Authorization"]
601+
headers["Authorization"] = str(r_session.headers["Authorization"])
602602
catalog = Client.open(root_url, headers=headers)
603603
catalog.validate()
604604
for child in catalog.get_children():

tests/test_main.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ def test_main_fails(runner: CliRunner) -> None:
1818
assert result.exit_code == 2
1919

2020

21-
def test_retrieve_called_with_auth_headers(runner: CliRunner) -> None:
21+
def test_retrieve_called_with_auth_headers(
22+
request: pytest.FixtureRequest, runner: CliRunner
23+
) -> None:
24+
if request.config.getoption("typeguard_packages"):
25+
pytest.skip(
26+
"The import hook that typeguard uses seems to break the mock below."
27+
)
28+
2229
expected_auth_header = {"Authorization": "api-key fake-api-key-value"}
2330
with unittest.mock.patch(
2431
"stac_api_validator.validations.retrieve"

0 commit comments

Comments
 (0)