Skip to content

refactor: make unleashconfig immutable and split params into groups - #457

Merged
alexanto merged 16 commits into
mainfrom
refactor/make-unleashconfig-immutable
Oct 28, 2026
Merged

alexanto merged 16 commits into
mainfrom
refactor/make-unleashconfig-immutable

Conversation

@alexanto

@alexanto alexanto commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the 26 flat constructor arguments of UnleashClient and AsyncUnleashClient with option groups, moves the API token to its own api_key argument, and makes the client's settings immutable.

Planned for release in v7. This is a breaking change.

# Before:
client = UnleashClient(
    url="https://YOUR-API-URL",
    app_name="my-python-app",
    environment="production",
    custom_headers={"Authorization": "<API token>"},
    refresh_interval=30,
    disable_metrics=True,
    experimental_mode={"type": "streaming"},
)

# After:
client = UnleashClient(
    "https://YOUR-API-URL",
    "my-python-app",
    api_key="<API token>",
    identity=IdentityOptions(environment="production"),
    mode=StreamingOptions(),  # or PollingOptions(interval=30)
    metrics=MetricsOptions(disabled=True),
)

What changes:

  • Option groups: settings are grouped into frozen dataclasses: IdentityOptions, HttpOptions, MetricsOptions, and a mode that is either PollingOptions or StreamingOptions.
  • api_key: the API token is its own argument instead of an Authorization entry in the custom headers. An Authorization header in HttpOptions.headers raises a ValueError, so an unmigrated v6 client fails at startup instead of silently getting 401s and serving cached flags.
  • Polling and streaming are separate types, with polling as default
  • Keyword-only arguments: everything after url and app_name (the two required arguments) must be passed by name
  • Immutable settings
    read-only. Their nrence, becauseoptions can hold objects that can't be copied, such as an SSL
    context.
  • Removed properties: the 19 unleash_* settings properties and their setters
  • ExperimentalMode removed

Docs: readme, changelog and migration guide added.

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change requires an update in the unleash-sdk-examples repo for the python app

How Has This Been Tested?

  • Unit tests, including some new ones
  • Spec Tests
  • Manual tests with the example app

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@alexanto alexanto changed the title Refactor/make unleashconfig immutable refactor: make unleashconfig immutable Oct 23, 2026
@alexanto
alexanto marked this pull request as ready for review October 23, 2026 12:07
@alexanto
alexanto requested review from ppicom and sighphyre and a balanced review from Copilot October 23, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Comment thread UnleashClient/_transport.py
Comment thread UnleashClient/config.py
Comment thread UnleashClient/config.py
Comment thread UnleashClient/config.py Outdated
Comment thread README.md Outdated
Comment thread UnleashClient/config.py
Comment thread UnleashClient/config.py
Comment thread UnleashClient/config.py Outdated
Comment thread README.md Outdated
Comment thread UnleashClient/_transport.py
Comment thread UnleashClient/config.py
Comment thread UnleashClient/config.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Mutable HTTP option dictionaries and shared nested values still allow request settings to change after construction, violating the immutability guarantee.

1 open issue

Review effort: Balanced

Comment thread UnleashClient/config.py Outdated
@alexanto
alexanto changed the base branch from main to chore/require-python-3.10 October 26, 2026 13:14
@alexanto
alexanto added this pull request to stack #459 October 26, 2026 13:14
Base automatically changed from chore/require-python-3.10 to main October 27, 2026 09:35
@alexanto
alexanto force-pushed the refactor/make-unleashconfig-immutable branch from b79e6bf to 02baa85 Compare October 27, 2026 13:13
@alexanto
alexanto force-pushed the refactor/make-unleashconfig-immutable branch from 23510cf to 6c14dc8 Compare October 27, 2026 13:37
@alexanto alexanto changed the title refactor: make unleashconfig immutable refactor: make unleashconfig immutable and split params into groups Oct 27, 2026
@alexanto
alexanto force-pushed the refactor/make-unleashconfig-immutable branch from e742280 to 7db242c Compare October 27, 2026 14:04
@gastonfournier gastonfournier moved this from New to In Progress in Issues and PRs Oct 28, 2026

@sighphyre sighphyre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm down. I like it @ppicom you have thoughts?

@github-project-automation github-project-automation Bot moved this from In Progress to Approved PRs in Issues and PRs Oct 28, 2026
@alexanto
alexanto force-pushed the refactor/make-unleashconfig-immutable branch from 32624c0 to 321248e Compare October 28, 2026 08:24
@ppicom

ppicom commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Nope @sighphyre, no thoughts. LGTM! 🚢 🇮🇹

@alexanto
alexanto merged commit 3a15d8a into main Oct 28, 2026
8 checks passed
@alexanto
alexanto deleted the refactor/make-unleashconfig-immutable branch October 28, 2026 08:32
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Issues and PRs Oct 28, 2026
@alexanto alexanto mentioned this pull request Oct 28, 2026
10 of 13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants