Skip to content

Commit d6b3ae4

Browse files
committed
chore: exempt tests from ANN, enable mypy-init-return
Align with ecosystem norms per review feedback: - Add mypy-init-return = true to skip -> None on __init__ when args are typed - Exempt tests/** from ANN rules (near-universal practice) - Revert test file annotations and __init__-only changes Shrinks diff from 149 to ~47 files, keeping the valuable src/ return type annotations that close the pyright gap.
1 parent eadfb25 commit d6b3ae4

File tree

115 files changed

+941
-1019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+941
-1019
lines changed

README.v2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class UserProfile:
518518
age: int
519519
email: str | None = None
520520

521-
def __init__(self, name: str, age: int, email: str | None = None) -> None:
521+
def __init__(self, name: str, age: int, email: str | None = None):
522522
self.name = name
523523
self.age = age
524524
self.email = email
@@ -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) -> None: # type: ignore[reportMissingParameterType] # noqa: ANN001
535+
def __init__(self, setting1, setting2): # type: ignore[reportMissingParameterType] # noqa: ANN001, ANN204
536536
self.setting1 = setting1
537537
self.setting2 = setting2
538538

examples/servers/simple-auth/mcp_simple_auth/auth_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SimpleAuthProvider(SimpleOAuthProvider):
4747
2. Stores token state for introspection by Resource Servers
4848
"""
4949

50-
def __init__(self, auth_settings: SimpleAuthSettings, auth_callback_path: str, server_url: str) -> None:
50+
def __init__(self, auth_settings: SimpleAuthSettings, auth_callback_path: str, server_url: str):
5151
super().__init__(auth_settings, auth_callback_path, server_url)
5252

5353

examples/servers/simple-auth/mcp_simple_auth/legacy_as_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ServerSettings(BaseModel):
3939
class LegacySimpleOAuthProvider(SimpleOAuthProvider):
4040
"""Simple OAuth provider for legacy MCP server."""
4141

42-
def __init__(self, auth_settings: SimpleAuthSettings, auth_callback_path: str, server_url: str) -> None:
42+
def __init__(self, auth_settings: SimpleAuthSettings, auth_callback_path: str, server_url: str):
4343
super().__init__(auth_settings, auth_callback_path, server_url)
4444

4545

examples/servers/simple-auth/mcp_simple_auth/simple_auth_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SimpleOAuthProvider(OAuthAuthorizationServerProvider[AuthorizationCode, Re
5151
3. Maintaining token state for introspection
5252
"""
5353

54-
def __init__(self, settings: SimpleAuthSettings, auth_callback_url: str, server_url: str) -> None:
54+
def __init__(self, settings: SimpleAuthSettings, auth_callback_url: str, server_url: str):
5555
self.settings = settings
5656
self.auth_callback_url = auth_callback_url
5757
self.server_url = server_url

examples/servers/simple-auth/mcp_simple_auth/token_verifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(
2525
introspection_endpoint: str,
2626
server_url: str,
2727
validate_resource: bool = False,
28-
) -> None:
28+
):
2929
self.introspection_endpoint = introspection_endpoint
3030
self.server_url = server_url
3131
self.validate_resource = validate_resource

examples/snippets/servers/structured_output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class UserProfile:
5757
age: int
5858
email: str | None = None
5959

60-
def __init__(self, name: str, age: int, email: str | None = None) -> None:
60+
def __init__(self, name: str, age: int, email: str | None = None):
6161
self.name = name
6262
self.age = age
6363
self.email = email
@@ -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) -> None: # type: ignore[reportMissingParameterType] # noqa: ANN001
74+
def __init__(self, setting1, setting2): # type: ignore[reportMissingParameterType] # noqa: ANN001, ANN204
7575
self.setting1 = setting1
7676
self.setting2 = setting2
7777

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ ignore = [
149149

150150
[tool.ruff.lint.flake8-annotations]
151151
allow-star-arg-any = true
152+
mypy-init-return = true
152153

153154
[tool.ruff.lint.flake8-tidy-imports.banned-api]
154155
"pydantic.RootModel".msg = "Use `pydantic.TypeAdapter` instead."
@@ -159,9 +160,8 @@ max-complexity = 24 # Default is 10
159160

160161
[tool.ruff.lint.per-file-ignores]
161162
"__init__.py" = ["F401"]
162-
# ANN001: these files intentionally define untyped parameters to test schema inference
163-
"tests/server/mcpserver/test_func_metadata.py" = ["ANN001", "E501"]
164-
"tests/server/mcpserver/test_server.py" = ["ANN001"]
163+
"tests/**" = ["ANN"]
164+
"tests/server/mcpserver/test_func_metadata.py" = ["E501"]
165165
"tests/shared/test_progress_notifications.py" = ["PLW0603"]
166166

167167
[tool.ruff.lint.pylint]

src/mcp/client/auth/oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def __init__(
232232
timeout: float = 300.0,
233233
client_metadata_url: str | None = None,
234234
validate_resource_url: Callable[[str, str | None], Awaitable[None]] | None = None,
235-
) -> None:
235+
):
236236
"""Initialize OAuth2 authentication.
237237
238238
Args:

src/mcp/os/win32/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class FallbackProcess:
7171
so that MCP clients expecting async streams can work properly.
7272
"""
7373

74-
def __init__(self, popen_obj: subprocess.Popen[bytes]) -> None:
74+
def __init__(self, popen_obj: subprocess.Popen[bytes]):
7575
self.popen: subprocess.Popen[bytes] = popen_obj
7676
self.stdin_raw = popen_obj.stdin # type: ignore[assignment]
7777
self.stdout_raw = popen_obj.stdout # type: ignore[assignment]

src/mcp/server/auth/middleware/auth_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AuthContextMiddleware:
2929
being stored in the context.
3030
"""
3131

32-
def __init__(self, app: ASGIApp) -> None:
32+
def __init__(self, app: ASGIApp):
3333
self.app = app
3434

3535
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:

0 commit comments

Comments
 (0)