Skip to content

Commit 81bd515

Browse files
Merge pull request #3216 from VWS-Python/codex/teach-ruff-beartype
Remove supported runtime-import suppressions
2 parents 6740f62 + 43f2168 commit 81bd515

18 files changed

Lines changed: 73 additions & 31 deletions

‎newsfragments/3216.change.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove supported inline type-checking comments by teaching Ruff about runtime-evaluated ``beartype`` annotations and postponing test annotations.

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ lint.flake8-tidy-imports.banned-api."operator.attrgetter".msg = "operator.attrge
161161
lint.flake8-tidy-imports.banned-api."typing.cast".msg = """\
162162
typing.cast is banned: use explicit type narrowing or a typed variable instead.\
163163
"""
164+
lint.flake8-type-checking.runtime-evaluated-decorators = [ "beartype.beartype" ]
164165
lint.pydocstyle.convention = "google"
165166
lint.preview = true
166167

‎src/vws/_async_vws_request.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from beartype import BeartypeConf, beartype
66
from vws_auth_tools import authorization_header, rfc_1123_date
77

8-
from vws.response import Response # noqa: TC001
9-
from vws.transports import AsyncTransport # noqa: TC001
8+
from vws.response import Response
9+
from vws.transports import AsyncTransport
1010

1111

1212
@beartype(conf=BeartypeConf(is_pep484_tower=True))

‎src/vws/_model_targets.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import base64
44
import json
5-
from collections.abc import Sequence # noqa: TC003
5+
from collections.abc import Sequence
66
from http import HTTPStatus
77
from typing import Any
88

@@ -18,13 +18,13 @@
1818
UnknownModelTargetDatasetError,
1919
)
2020
from vws.exceptions.vws_exceptions import TooManyRequestsError
21-
from vws.model_target_datasets import ( # noqa: TC001
21+
from vws.model_target_datasets import (
2222
ModelTargetDatasetType,
2323
ModelTargetModel,
2424
ModelTargetView,
2525
)
2626
from vws.reports import ModelTargetDatasetStatusReport
27-
from vws.response import Response # noqa: TC001
27+
from vws.response import Response
2828

2929
OAUTH2_TOKEN_PATH = "/oauth2/token" # noqa: S105
3030
OAUTH2_TOKEN_BODY = b"grant_type=client_credentials"

‎src/vws/_reco_counts.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Internal helpers for the database reco counts report endpoints."""
22

3-
import calendar # noqa: TC003
3+
import calendar
44
import json
55
from http import HTTPStatus
66

@@ -12,7 +12,7 @@
1212
RecoCountsReportNotReadyError,
1313
)
1414
from vws.reports import RecoCountsReport
15-
from vws.response import Response # noqa: TC001
15+
from vws.response import Response
1616

1717

1818
@beartype(conf=BeartypeConf(is_pep484_tower=True))

‎src/vws/_vws_request.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from beartype import BeartypeConf, beartype
66
from vws_auth_tools import authorization_header, rfc_1123_date
77

8-
from vws.response import Response # noqa: TC001
9-
from vws.transports import Transport # noqa: TC001
8+
from vws.response import Response
9+
from vws.transports import Transport
1010

1111

1212
@beartype(conf=BeartypeConf(is_pep484_tower=True))

‎src/vws/exceptions/model_target_exceptions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from beartype import beartype
1111

1212
from vws.reports import ModelTargetGenerationDetail
13-
from vws.response import Response # noqa: TC001
13+
from vws.response import Response
1414

1515

1616
@beartype

‎src/vws/model_target_datasets.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
https://developer.vuforia.com/library/vuforia-engine/web-api/model-target-web-api/.
55
"""
66

7-
from collections.abc import Sequence # noqa: TC003
7+
from collections.abc import Sequence
88
from dataclasses import dataclass
99
from enum import StrEnum, unique
1010

‎src/vws/reports.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import csv
44
import datetime
55
import io
6-
from collections.abc import Sequence # noqa: TC003
6+
from collections.abc import Sequence
77
from dataclasses import dataclass
88
from enum import Enum, unique
99
from typing import Any, Self

‎tests/conftest.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Configuration, plugins and fixtures for `pytest`."""
22

3+
from __future__ import annotations
4+
35
import datetime
4-
import io # noqa: TC003
5-
from collections.abc import AsyncGenerator, Generator # noqa: TC003
6-
from pathlib import Path # noqa: TC003
7-
from typing import BinaryIO, Literal
6+
from typing import TYPE_CHECKING, BinaryIO, Literal
87

98
import pytest
109
import pytest_asyncio
@@ -29,6 +28,11 @@
2928
ModelTargetView,
3029
)
3130

31+
if TYPE_CHECKING:
32+
import io
33+
from collections.abc import AsyncGenerator, Generator
34+
from pathlib import Path
35+
3236
# The mock accepts one hard-coded pair of Model Target Web API OAuth2
3337
# credentials, which it does not expose.
3438
_MODEL_TARGET_CLIENT_ID = "client-id"

0 commit comments

Comments
 (0)