Skip to content

Commit 66bde61

Browse files
pcarletonclaude
andcommitted
Fix lint issues in conformance-auth-client
- Add type annotations for ParseResult and query_params dict - Fix unused variable warning by using underscore for session_id - Update logger.exception to not include exception in message - Use relative import in __main__.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bc2edf4 commit 66bde61

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

examples/clients/conformance-auth-client/mcp_conformance_auth_client/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import logging
1515
import sys
1616
from datetime import timedelta
17-
from urllib.parse import parse_qs, urlparse
17+
from urllib.parse import ParseResult, parse_qs, urlparse
1818

1919
import httpx
2020
from mcp import ClientSession
@@ -83,12 +83,13 @@ async def handle_redirect(self, authorization_url: str) -> None:
8383
if response.status_code in (301, 302, 303, 307, 308):
8484
location = response.headers.get("location")
8585
if location:
86-
redirect_url = urlparse(location)
87-
query_params = parse_qs(redirect_url.query)
86+
redirect_url: ParseResult = urlparse(location)
87+
query_params: dict[str, list[str]] = parse_qs(redirect_url.query)
8888

8989
if "code" in query_params:
9090
self._auth_code = query_params["code"][0]
91-
self._state = query_params.get("state", [None])[0]
91+
state_values = query_params.get("state")
92+
self._state = state_values[0] if state_values else None
9293
logger.debug(f"Got auth code from redirect: {self._auth_code[:10]}...")
9394
return
9495
else:
@@ -145,7 +146,7 @@ async def run_client(server_url: str) -> None:
145146
auth=oauth_auth,
146147
timeout=timedelta(seconds=30),
147148
sse_read_timeout=timedelta(seconds=60),
148-
) as (read_stream, write_stream, get_session_id):
149+
) as (read_stream, write_stream, _):
149150
async with ClientSession(read_stream, write_stream) as session:
150151
# Initialize the session
151152
await session.initialize()
@@ -175,8 +176,8 @@ def main() -> None:
175176

176177
try:
177178
asyncio.run(run_client(server_url))
178-
except Exception as e:
179-
logger.exception(f"Client failed: {e}")
179+
except Exception:
180+
logger.exception("Client failed")
180181
sys.exit(1)
181182

182183

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Allow running the module with python -m."""
22

3-
from mcp_conformance_auth_client import main
3+
from . import main
44

55
if __name__ == "__main__":
66
main()

0 commit comments

Comments
 (0)