Skip to content

refactor: make set_credentials synchronous in InMemoryContextCredentialStore#1

Merged
odanilosalve merged 1 commit into
mainfrom
refactor/remove-async-set-credentials
Jun 28, 2026
Merged

refactor: make set_credentials synchronous in InMemoryContextCredentialStore#1
odanilosalve merged 1 commit into
mainfrom
refactor/remove-async-set-credentials

Conversation

@odanilosalve

@odanilosalve odanilosalve commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Description

Fix multiple SonarQube issues across the client auth and transports modules.

Changes

1. Make set_credentials synchronous (SonarQube S7503)

  • src/a2a/client/auth/credentials.py — removed async from InMemoryContextCredentialStore.set_credentials (pure dict operations, no I/O)
  • tests/client/test_auth_interceptor.py — removed await from 4 call sites

2. Reduce cognitive complexity in AuthInterceptor.before (SonarQube S3776)

  • src/a2a/client/auth/interceptor.py — extracted _apply_credential, _ensure_context, _apply_bearer, _apply_api_key helper methods to reduce nesting

3. Fix transport issues (SonarQube S1763, S112, S3776)

  • src/a2a/client/transports/base.py — added # noqa: S1763 for necessary yield in abstract async generators
  • src/a2a/client/transports/jsonrpc.py — replaced generic Exception with A2AError in _create_jsonrpc_error return type
  • src/a2a/client/transports/rest.py — extracted _is_error_info and _extract_error_info helpers to reduce cognitive complexity in _parse_rest_error

4. Remove redundant exception catch (SonarQube S5713)

  • src/a2a/client/transports/rest.py — removed redundant json.JSONDecodeError from except (subclass of ValueError)

Checklist

  • Tests pass (195/195)
  • Lint and type checks pass
  • Follows conventional commits spec

@odanilosalve odanilosalve merged commit 1a719ac into main Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant