Skip to content

fix: use correct default factory for headers and preserve subclass types in replace() #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DaleStack
Copy link

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

  1. headers field uses DEFAULT_HEADERS.copy directly, which evaluates at module load time. This can lead to shared state across instances.
  2. The replace() method instantiates ClientOptions() directly, breaking subclass behavior for AsyncClientOptions and SyncClientOptions.

What is the new behavior?

  • The headers field now uses a lambda to ensure a fresh copy of DEFAULT_HEADERS per instance.
  • The replace() method now uses type(self)() to preserve subclass overrides.

Additional context

This PR only addresses the bugs listed above.

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