Skip to content

Commit 91a983f

Browse files
committed
chore: ignore ANN204 to allow __init__ without return type
Replaces mypy-init-return (which only exempts __init__ when args are typed) with a blanket ANN204 ignore. Special methods have well-known return types and pyright infers them correctly.
1 parent cfde91d commit 91a983f

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

README.v2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def get_user(user_id: str) -> UserProfile:
532532

533533
# Classes WITHOUT type hints cannot be used for structured output
534534
class UntypedConfig:
535-
def __init__(self, setting1, setting2): # type: ignore[reportMissingParameterType] # noqa: ANN001, ANN204
535+
def __init__(self, setting1, setting2): # type: ignore[reportMissingParameterType] # noqa: ANN001
536536
self.setting1 = setting1
537537
self.setting2 = setting2
538538

@@ -2327,7 +2327,7 @@ from mcp.shared.auth import OAuthClientInformationFull, OAuthClientMetadata, OAu
23272327
class InMemoryTokenStorage(TokenStorage):
23282328
"""Demo In-memory token storage implementation."""
23292329

2330-
def __init__(self) -> None:
2330+
def __init__(self):
23312331
self.tokens: OAuthToken | None = None
23322332
self.client_info: OAuthClientInformationFull | None = None
23332333

examples/snippets/clients/oauth_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class InMemoryTokenStorage(TokenStorage):
2222
"""Demo In-memory token storage implementation."""
2323

24-
def __init__(self) -> None:
24+
def __init__(self):
2525
self.tokens: OAuthToken | None = None
2626
self.client_info: OAuthClientInformationFull | None = None
2727

examples/snippets/servers/structured_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_user(user_id: str) -> UserProfile:
7171

7272
# Classes WITHOUT type hints cannot be used for structured output
7373
class UntypedConfig:
74-
def __init__(self, setting1, setting2): # type: ignore[reportMissingParameterType] # noqa: ANN001, ANN204
74+
def __init__(self, setting1, setting2): # type: ignore[reportMissingParameterType] # noqa: ANN001
7575
self.setting1 = setting1
7676
self.setting2 = setting2
7777

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ select = [
143143
"TID251", # https://docs.astral.sh/ruff/rules/banned-api/
144144
]
145145
ignore = [
146+
"ANN204", # special methods (__init__, __enter__, etc.) have well-known return types
146147
"ANN401", # `Any` is sometimes the right type; pyright strict handles real misuse
147148
"PERF203",
148149
]
149150

150151
[tool.ruff.lint.flake8-annotations]
151152
allow-star-arg-any = true
152-
mypy-init-return = true
153153

154154
[tool.ruff.lint.flake8-tidy-imports.banned-api]
155155
"pydantic.RootModel".msg = "Use `pydantic.TypeAdapter` instead."

0 commit comments

Comments
 (0)