Skip to content

Implement global shade module configuration #1

Description

@codebestia

Description:

The SDK should support module-level configuration (e.g. shade.api_key = "sk_live_...") so developers can configure it once at app startup without instantiating a client object on every call. This mirrors the ergonomics of the Stripe Python SDK. The global config must be thread-safe and readable by all resource classes.

Proposed Steps:

  • Create src/shade/config.py with module-level variables: api_key, api_base, environment, timeout, max_retries.
  • Expose these on the top-level shade namespace via __init__.py.
  • Write a get_config() helper that merges instance-level overrides with global defaults, used internally by all resource methods.
  • Guard against None api_key at request time and raise AuthenticationError.

Acceptance Criteria:

  • shade.api_key = "sk_live_xxx" sets the global key accessible across all resource calls.
  • shade.environment = "sandbox" switches the active environment.
  • Setting shade.api_key = None and then calling any resource raises AuthenticationError with a clear message.
  • Global config does not bleed between threads when changed concurrently.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions