Skip to content

Commit 0c15371

Browse files
mivertowskiclaude
andcommitted
fix: use typing.List/Optional to avoid mypy list method shadowing
Classes with a list() method cause mypy to interpret list[str] as a method call. Switch to typing.List and typing.Optional in api_keys.py and webhooks.py, with per-file ruff ignores for the UP006/UP035/UP045 rules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b741512 commit 0c15371

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ line-length = 100
4242
[tool.ruff.lint]
4343
select = ["E", "F", "I", "UP", "B", "SIM"]
4444

45+
[tool.ruff.lint.per-file-ignores]
46+
# These files define a list() method which shadows the builtin;
47+
# mypy needs typing.List to avoid interpreting list[str] as the method.
48+
"src/vynfi/resources/api_keys.py" = ["UP006", "UP035", "UP045"]
49+
"src/vynfi/resources/webhooks.py" = ["UP006", "UP035", "UP045"]
50+
4551
[tool.mypy]
4652
python_version = "3.9"
4753
strict = true

src/vynfi/resources/api_keys.py

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

33
from __future__ import annotations
44

5-
from typing import Any
5+
from typing import Any, List, Optional
66

77
from .._client import SyncClient
88
from .._types import ApiKey, ApiKeyCreated
@@ -18,8 +18,8 @@ def create(
1818
self,
1919
*,
2020
name: str,
21-
scopes: list[str] | None = None,
22-
expires_in_days: int | None = None,
21+
scopes: Optional[List[str]] = None,
22+
expires_in_days: Optional[int] = None,
2323
) -> ApiKeyCreated:
2424
"""Create a new API key.
2525
@@ -33,7 +33,7 @@ def create(
3333
data = self._client.request("POST", "/v1/api-keys", json=body)
3434
return ApiKeyCreated.model_validate(data)
3535

36-
def list(self) -> list[ApiKey]:
36+
def list(self) -> List[ApiKey]:
3737
"""List all API keys (masked)."""
3838
data = self._client.request("GET", "/v1/api-keys")
3939
if isinstance(data, dict):
@@ -49,8 +49,8 @@ def update(
4949
self,
5050
key_id: str,
5151
*,
52-
name: str | None = None,
53-
scopes: list[str] | None = None,
52+
name: Optional[str] = None,
53+
scopes: Optional[List[str]] = None,
5454
) -> ApiKey:
5555
"""Update an API key."""
5656
body: dict[str, Any] = {}

src/vynfi/resources/webhooks.py

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

33
from __future__ import annotations
44

5-
from typing import Any
5+
from typing import Any, List, Optional
66

77
from .._client import SyncClient
88
from .._types import Webhook, WebhookCreated
@@ -14,7 +14,7 @@ class Webhooks:
1414
def __init__(self, client: SyncClient) -> None:
1515
self._client = client
1616

17-
def create(self, *, url: str, events: list[str]) -> WebhookCreated:
17+
def create(self, *, url: str, events: List[str]) -> WebhookCreated:
1818
"""Create a new webhook.
1919
2020
Args:
@@ -25,7 +25,7 @@ def create(self, *, url: str, events: list[str]) -> WebhookCreated:
2525
data = self._client.request("POST", "/v1/webhooks", json={"url": url, "events": events})
2626
return WebhookCreated.model_validate(data)
2727

28-
def list(self) -> list[Webhook]:
28+
def list(self) -> List[Webhook]:
2929
"""List all webhooks."""
3030
data = self._client.request("GET", "/v1/webhooks")
3131
if isinstance(data, dict):
@@ -41,9 +41,9 @@ def update(
4141
self,
4242
webhook_id: str,
4343
*,
44-
url: str | None = None,
45-
events: list[str] | None = None,
46-
status: str | None = None,
44+
url: Optional[str] = None,
45+
events: Optional[List[str]] = None,
46+
status: Optional[str] = None,
4747
) -> Webhook:
4848
"""Update a webhook."""
4949
body: dict[str, Any] = {}
@@ -60,7 +60,6 @@ def delete(self, webhook_id: str) -> None:
6060
"""Delete a webhook."""
6161
self._client.request("DELETE", f"/v1/webhooks/{webhook_id}")
6262

63-
def test(self, webhook_id: str) -> dict[str, Any]:
63+
def test(self, webhook_id: str) -> Any:
6464
"""Send a test event to a webhook."""
65-
data = self._client.request("POST", f"/v1/webhooks/{webhook_id}/test")
66-
return data # type: ignore[return-value]
65+
return self._client.request("POST", f"/v1/webhooks/{webhook_id}/test")

0 commit comments

Comments
 (0)