fix config: honor explicit args instead of returning cached default - #166
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
upstox_client/configuration.py:TypeWithDefault.__call__now constructs a freshConfigurationwhen explicit args/kwargs are passed, instead of always returning a copy of the first-cached default. BareConfiguration()calls keep the existing cached-default behavior, andApiClient(which callsConfiguration()with no args) is unaffected.test/test_configuration.pywith 4 network-free unit tests.Why
Fixes #155. Once any
Configuration()was created (e.g. live), a laterConfiguration(sandbox=True)silently returned a copy of the live config, so sandbox endpoints were never used unless callers hand-patchedhost/order_host.Testing
Docker
python:3.11-bookworm:python -m unittest test.test_configuration— 4 passed with the fix; 3 fail on base (the sandbox-arg cases), 1 passes both (bare-call caching, by design).python -m compileall -q upstox_client/configuration.py test/test_configuration.py— OK.urllib3.get_host) was checked while triaging — noget_hostusage remains in the current tree, so only Configuration Class behaves as a Singleton, ignoring subsequent __init__ arguments #155 is addressed here.