From 216345ea6e15ca962243cb5a58925222dd0156cb Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 11 Jul 2026 15:54:52 -0700 Subject: [PATCH] feat: improved client performance when Bypasser is disabled --- .github/workflows/publish-anaconda.yml | 2 +- sonar-project.properties | 2 +- switcher_client/lib/bypasser/bypasser.py | 6 ++++++ switcher_client/version.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-anaconda.yml b/.github/workflows/publish-anaconda.yml index 9a86a66..d733930 100644 --- a/.github/workflows/publish-anaconda.yml +++ b/.github/workflows/publish-anaconda.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: version: - description: 'Package version to publish (e.g. 1.2.0). Leave empty to read from version.py' + description: 'Package version to publish (e.g. 1.2.1). Leave empty to read from version.py' required: false jobs: diff --git a/sonar-project.properties b/sonar-project.properties index c4785c1..eacd223 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=switcherapi_switcher-client-py sonar.projectName=switcher-client-py sonar.organization=switcherapi -sonar.projectVersion=1.2.0 +sonar.projectVersion=1.2.1 sonar.links.homepage=https://github.com/switcherapi/switcher-client-py sonar.sources=switcher_client diff --git a/switcher_client/lib/bypasser/bypasser.py b/switcher_client/lib/bypasser/bypasser.py index 7cd57d1..6447fd3 100644 --- a/switcher_client/lib/bypasser/bypasser.py +++ b/switcher_client/lib/bypasser/bypasser.py @@ -8,9 +8,12 @@ class Bypasser: """ _bypassed_keys: ContextVar[dict[str, Key] | None] = ContextVar('bypassed_keys', default=None) + _bypass_enabled = False @staticmethod def assume(key: str) -> Key: + Bypasser._bypass_enabled = True + # Remove previous forced value if exists to avoid conflicts new_key = Key(key) bypassed_keys = dict(Bypasser._current_keys()) @@ -29,6 +32,9 @@ def forget(key: str) -> None: @staticmethod def search_key(key: str) -> Key | None: """ Search for key registered via 'assume' """ + if not Bypasser._bypass_enabled: + return None + return Bypasser._current_keys().get(key) @staticmethod diff --git a/switcher_client/version.py b/switcher_client/version.py index c68196d..a955fda 100644 --- a/switcher_client/version.py +++ b/switcher_client/version.py @@ -1 +1 @@ -__version__ = "1.2.0" +__version__ = "1.2.1"