switcher-client 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- switcher_client-0.1.2/LICENSE +21 -0
- switcher_client-0.1.2/PKG-INFO +402 -0
- switcher_client-0.1.2/README.md +372 -0
- switcher_client-0.1.2/pyproject.toml +57 -0
- switcher_client-0.1.2/setup.cfg +4 -0
- switcher_client-0.1.2/switcher_client/__init__.py +11 -0
- switcher_client-0.1.2/switcher_client/client.py +262 -0
- switcher_client-0.1.2/switcher_client/errors/__init__.py +44 -0
- switcher_client-0.1.2/switcher_client/lib/__init__.py +7 -0
- switcher_client-0.1.2/switcher_client/lib/compat.py +8 -0
- switcher_client-0.1.2/switcher_client/lib/globals/__init__.py +10 -0
- switcher_client-0.1.2/switcher_client/lib/globals/global_auth.py +28 -0
- switcher_client-0.1.2/switcher_client/lib/globals/global_context.py +95 -0
- switcher_client-0.1.2/switcher_client/lib/globals/global_retry.py +16 -0
- switcher_client-0.1.2/switcher_client/lib/globals/global_snapshot.py +33 -0
- switcher_client-0.1.2/switcher_client/lib/remote.py +153 -0
- switcher_client-0.1.2/switcher_client/lib/remote_auth.py +74 -0
- switcher_client-0.1.2/switcher_client/lib/resolver.py +99 -0
- switcher_client-0.1.2/switcher_client/lib/snapshot.py +214 -0
- switcher_client-0.1.2/switcher_client/lib/snapshot_auto_updater.py +63 -0
- switcher_client-0.1.2/switcher_client/lib/snapshot_loader.py +77 -0
- switcher_client-0.1.2/switcher_client/lib/snapshot_watcher.py +67 -0
- switcher_client-0.1.2/switcher_client/lib/types.py +169 -0
- switcher_client-0.1.2/switcher_client/lib/utils/__init__.py +21 -0
- switcher_client-0.1.2/switcher_client/lib/utils/date_moment.py +26 -0
- switcher_client-0.1.2/switcher_client/lib/utils/execution_logger.py +96 -0
- switcher_client-0.1.2/switcher_client/lib/utils/ipcidr.py +46 -0
- switcher_client-0.1.2/switcher_client/lib/utils/payload_reader.py +43 -0
- switcher_client-0.1.2/switcher_client/lib/utils/timed_match/__init__.py +3 -0
- switcher_client-0.1.2/switcher_client/lib/utils/timed_match/timed_match.py +246 -0
- switcher_client-0.1.2/switcher_client/lib/utils/timed_match/worker.py +100 -0
- switcher_client-0.1.2/switcher_client/switcher.py +188 -0
- switcher_client-0.1.2/switcher_client/switcher_data.py +112 -0
- switcher_client-0.1.2/switcher_client/version.py +1 -0
- switcher_client-0.1.2/switcher_client.egg-info/PKG-INFO +402 -0
- switcher_client-0.1.2/switcher_client.egg-info/SOURCES.txt +48 -0
- switcher_client-0.1.2/switcher_client.egg-info/dependency_links.txt +1 -0
- switcher_client-0.1.2/switcher_client.egg-info/requires.txt +4 -0
- switcher_client-0.1.2/switcher_client.egg-info/top_level.txt +1 -0
- switcher_client-0.1.2/tests/test_client_check_switchers.py +99 -0
- switcher_client-0.1.2/tests/test_client_context.py +46 -0
- switcher_client-0.1.2/tests/test_client_load_snapshot_file.py +52 -0
- switcher_client-0.1.2/tests/test_client_load_snapshot_remote.py +195 -0
- switcher_client-0.1.2/tests/test_client_watch_snapshot.py +118 -0
- switcher_client-0.1.2/tests/test_switcher_integration.py +71 -0
- switcher_client-0.1.2/tests/test_switcher_local.py +280 -0
- switcher_client-0.1.2/tests/test_switcher_logger.py +138 -0
- switcher_client-0.1.2/tests/test_switcher_remote.py +238 -0
- switcher_client-0.1.2/tests/test_switcher_silent_mode.py +63 -0
- switcher_client-0.1.2/tests/test_switcher_throttle.py +69 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Roger Floriano (petruki) and Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: switcher-client
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Switcher Client SDK for Python
|
|
5
|
+
Author-email: "Roger Floriano (petruki)" <switcher.project@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: homepage, https://github.com/switcherapi
|
|
8
|
+
Project-URL: source, https://github.com/switcherapi/switcher-client-py
|
|
9
|
+
Project-URL: issue-tracker, https://github.com/switcherapi/switcher-client-py/issues
|
|
10
|
+
Project-URL: release-notes, https://github.com/switcherapi/switcher-client-py/releases
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
|
+
Classifier: Operating System :: OS Independent
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: httpx[http2]>=0.28.1
|
|
28
|
+
Requires-Dist: typing_extensions>=4.0; python_version <= "3.12"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
<b>Switcher Client SDK</b><br>
|
|
35
|
+
A Python SDK for Switcher API
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div align="center">
|
|
39
|
+
|
|
40
|
+
[](https://github.com/switcherapi/switcher-client-py/actions/workflows/master.yml)
|
|
41
|
+
[](https://sonarcloud.io/dashboard?id=switcherapi_switcher-client-py)
|
|
42
|
+
[](https://pypi.org/project/switcher-client/)
|
|
43
|
+
[](https://anaconda.org/switcherapi/switcher-client)
|
|
44
|
+
[](https://www.python.org/downloads/)
|
|
45
|
+
[](https://opensource.org/licenses/MIT)
|
|
46
|
+
[](https://switcher-hq.slack.com/)
|
|
47
|
+
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
***
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Table of Contents
|
|
59
|
+
|
|
60
|
+
- [Quick Start](#quick-start)
|
|
61
|
+
- [Installation](#installation)
|
|
62
|
+
- [Configuration](#configuration)
|
|
63
|
+
- [Usage Examples](#usage-examples)
|
|
64
|
+
- [Advanced Features](#advanced-features)
|
|
65
|
+
- [Snapshot Management](#snapshot-management)
|
|
66
|
+
- [Testing & Development](#testing--development)
|
|
67
|
+
- [Contributing](#contributing)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## About
|
|
72
|
+
|
|
73
|
+
The **Switcher Client SDK for Python** provides seamless integration with [Switcher-API](https://github.com/switcherapi/switcher-api), enabling powerful feature flag management in your Python applications.
|
|
74
|
+
|
|
75
|
+
### Key Features
|
|
76
|
+
|
|
77
|
+
- **Clean & Maintainable**: Flexible and robust functions that keep your code organized
|
|
78
|
+
- **Local Mode**: Work offline using snapshot files from your Switcher-API Domain
|
|
79
|
+
- **Silent Mode**: Hybrid configuration with automatic fallback for connectivity issues
|
|
80
|
+
- **Built-in Mocking**: Easy implementation of automated testing with mock support
|
|
81
|
+
- **Zero Latency**: Local snapshot execution for high-performance scenarios
|
|
82
|
+
- **Secure**: Built-in protection against ReDoS attacks with regex safety features
|
|
83
|
+
- **Monitoring**: Comprehensive logging and error handling capabilities
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
Get up and running in just a few lines of code:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from switcher_client import Client
|
|
91
|
+
|
|
92
|
+
# Initialize the client
|
|
93
|
+
Client.build_context(
|
|
94
|
+
domain='My Domain',
|
|
95
|
+
url='https://api.switcherapi.com',
|
|
96
|
+
api_key='[YOUR_API_KEY]',
|
|
97
|
+
component='MyApp',
|
|
98
|
+
environment='default'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Use feature flags
|
|
102
|
+
switcher = Client.get_switcher()
|
|
103
|
+
if switcher.is_on('FEATURE_TOGGLE'):
|
|
104
|
+
print("Feature is enabled!")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Installation
|
|
108
|
+
|
|
109
|
+
Install the Switcher Client SDK:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Pip
|
|
113
|
+
pip install switcher-client
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Conda
|
|
118
|
+
conda install switcherapi::switcher-client
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### System Requirements
|
|
123
|
+
- **Python**: 3.9+ (supports 3.9, 3.10, 3.11, 3.12, 3.13, 3.14)
|
|
124
|
+
- **Operating System**: Cross-platform (Windows, macOS, Linux)
|
|
125
|
+
|
|
126
|
+
## Configuration
|
|
127
|
+
|
|
128
|
+
### Basic Setup
|
|
129
|
+
|
|
130
|
+
Initialize the Switcher Client with your domain configuration:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from switcher_client import Client
|
|
134
|
+
|
|
135
|
+
Client.build_context(
|
|
136
|
+
domain='My Domain', # Your Switcher domain name
|
|
137
|
+
url='https://api.switcherapi.com', # Switcher-API endpoint (optional)
|
|
138
|
+
api_key='[YOUR_API_KEY]', # Your component's API key (optional)
|
|
139
|
+
component='MyApp', # Your application name (optional)
|
|
140
|
+
environment='default' # Environment ('default' for production)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
switcher = Client.get_switcher()
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Configuration Parameters
|
|
147
|
+
|
|
148
|
+
| Parameter | Required | Description | Default |
|
|
149
|
+
|-----------|----------|-------------|---------|
|
|
150
|
+
| `domain` | ✅ | Your Switcher domain name | - |
|
|
151
|
+
| `url` | | Switcher-API endpoint | `https://api.switcherapi.com` |
|
|
152
|
+
| `api_key` | | API key for your component | - |
|
|
153
|
+
| `component` | | Your application identifier | - |
|
|
154
|
+
| `environment` | | Target environment | `default` |
|
|
155
|
+
|
|
156
|
+
### Advanced Configuration
|
|
157
|
+
|
|
158
|
+
Enable additional features like local mode, silent mode, and security options:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from switcher_client import Client, ContextOptions
|
|
162
|
+
|
|
163
|
+
Client.build_context(
|
|
164
|
+
domain='My Domain',
|
|
165
|
+
url='https://api.switcherapi.com',
|
|
166
|
+
api_key='[YOUR_API_KEY]',
|
|
167
|
+
component='MyApp',
|
|
168
|
+
environment='default',
|
|
169
|
+
options=ContextOptions(
|
|
170
|
+
local=True,
|
|
171
|
+
logger=True,
|
|
172
|
+
freeze=True,
|
|
173
|
+
snapshot_location='./snapshot/',
|
|
174
|
+
snapshot_auto_update_interval=3,
|
|
175
|
+
silent_mode='5m',
|
|
176
|
+
restrict_relay=True,
|
|
177
|
+
throttle_max_workers=2,
|
|
178
|
+
regex_max_black_list=10,
|
|
179
|
+
regex_max_time_limit=100,
|
|
180
|
+
cert_path='./certs/ca.pem'
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
switcher = Client.get_switcher()
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Advanced Options Reference
|
|
188
|
+
|
|
189
|
+
| Option | Type | Description | Default |
|
|
190
|
+
|--------|------|-------------|---------|
|
|
191
|
+
| `local` | `bool` | Use local snapshot files only (zero latency) | `False` |
|
|
192
|
+
| `logger` | `bool` | Enable logging/caching of feature flag evaluations | `False` |
|
|
193
|
+
| `freeze` | `bool` | Enable cache-immutability responses for consistent results | `False` |
|
|
194
|
+
| `snapshot_location` | `str` | Directory for snapshot files | `'./snapshot/'` |
|
|
195
|
+
| `snapshot_auto_update_interval` | `int` | Auto-update interval in seconds (0 = disabled) | `0` |
|
|
196
|
+
| `silent_mode` | `str` | Silent mode retry time (e.g., '5m' for 5 minutes) | `None` |
|
|
197
|
+
| `restrict_relay` | `bool` | Enable relay restrictions in local mode | `True` |
|
|
198
|
+
| `throttle_max_workers` | `int` | Max workers for throttling feature checks | `None` |
|
|
199
|
+
| `regex_max_black_list` | `int` | Max cached entries for failed regex | `100` |
|
|
200
|
+
| `regex_max_time_limit` | `int` | Regex execution time limit (ms) | `3000` |
|
|
201
|
+
| `cert_path` | `str` | Path to custom certificate for secure API connections | `None` |
|
|
202
|
+
|
|
203
|
+
#### Security Features
|
|
204
|
+
|
|
205
|
+
- **ReDoS Protection**: Built-in ReDoS attack prevention with regex safety features
|
|
206
|
+
- **Time Limits**: Configurable timeouts prevent long-running regex operations
|
|
207
|
+
- **Certificate Support**: Use custom certificates for secure API connections
|
|
208
|
+
|
|
209
|
+
## Usage Examples
|
|
210
|
+
|
|
211
|
+
### Basic Feature Flag Checking
|
|
212
|
+
|
|
213
|
+
The simplest way to check if a feature is enabled:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
switcher = Client.get_switcher()
|
|
217
|
+
|
|
218
|
+
# Simple boolean check
|
|
219
|
+
if switcher.is_on('FEATURE_LOGIN_V2'):
|
|
220
|
+
# Use new login system
|
|
221
|
+
new_login()
|
|
222
|
+
else:
|
|
223
|
+
# Use legacy login
|
|
224
|
+
legacy_login()
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Detailed Response Information
|
|
228
|
+
|
|
229
|
+
Get comprehensive information about the feature flag evaluation:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
response = switcher.is_on_with_details('FEATURE_LOGIN_V2')
|
|
233
|
+
|
|
234
|
+
print(f"Feature enabled: {response.result}") # True or False
|
|
235
|
+
print(f"Reason: {response.reason}") # Evaluation reason
|
|
236
|
+
print(f"Metadata: {response.metadata}") # Additional context
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Strategy-Based Feature Flags
|
|
240
|
+
|
|
241
|
+
#### Method 1: Prepare and Execute
|
|
242
|
+
|
|
243
|
+
Load validation data separately, useful for complex applications:
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
# Prepare the validation context
|
|
247
|
+
switcher.check_value('USER_123').prepare('USER_FEATURE')
|
|
248
|
+
|
|
249
|
+
# Execute when ready
|
|
250
|
+
if switcher.is_on():
|
|
251
|
+
enable_user_feature()
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
#### Method 2: All-in-One Execution
|
|
255
|
+
|
|
256
|
+
Chain multiple validation strategies for comprehensive feature control:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
is_enabled = switcher \
|
|
260
|
+
# VALUE strategy
|
|
261
|
+
.check_value('premium_user') \
|
|
262
|
+
# NETWORK strategy
|
|
263
|
+
.check_network('192.168.1.0/24') \
|
|
264
|
+
# Fallback value if API fails
|
|
265
|
+
.default_result(True) \
|
|
266
|
+
# Cache result for 1 second
|
|
267
|
+
.throttle(1000) \
|
|
268
|
+
.is_on('PREMIUM_FEATURES')
|
|
269
|
+
|
|
270
|
+
if is_enabled:
|
|
271
|
+
show_premium_dashboard()
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Error Handling
|
|
275
|
+
|
|
276
|
+
Subscribe to error notifications for robust error management:
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
# Set up error handling
|
|
280
|
+
Client.subscribe_notify_error(lambda error: print(f"Switcher Error: {error}"))
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Advanced Features
|
|
284
|
+
|
|
285
|
+
#### Throttling
|
|
286
|
+
```python
|
|
287
|
+
# Zero-latency async execution
|
|
288
|
+
switcher.throttle(1000).is_on('FEATURE01')
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
#### Hybrid Mode
|
|
292
|
+
```python
|
|
293
|
+
# Force remote resolution for specific features
|
|
294
|
+
switcher.remote().is_on('FEATURE01')
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Snapshot Management
|
|
298
|
+
|
|
299
|
+
### Loading Snapshots
|
|
300
|
+
|
|
301
|
+
Load configuration snapshots from the API for local/offline usage:
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
# Download and save snapshot from API
|
|
305
|
+
Client.load_snapshot()
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Version Management
|
|
309
|
+
|
|
310
|
+
Check your current snapshot version:
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
# Verify snapshot version
|
|
314
|
+
version_info = Client.check_snapshot()
|
|
315
|
+
print(f"Current snapshot version: {Client.snapshot_version()}")
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Automated Updates
|
|
319
|
+
|
|
320
|
+
Schedule automatic snapshot updates for zero-latency local mode:
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
Client.schedule_snapshot_auto_update(
|
|
324
|
+
interval=60,
|
|
325
|
+
callback=lambda error, updated: (
|
|
326
|
+
print(f"Snapshot updated to version: {Client.snapshot_version()}") if updated else None
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Snapshot Monitoring
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
# Watch for snapshot file changes
|
|
335
|
+
Client.watch_snapshot(WatchSnapshotCallback(
|
|
336
|
+
success=lambda: print("✅ Snapshot loaded successfully"),
|
|
337
|
+
reject=lambda e: print(f"❌ Error loading snapshot: {e}")
|
|
338
|
+
))
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Testing & Development
|
|
342
|
+
|
|
343
|
+
### Built-in Mocking (Coming Soon)
|
|
344
|
+
|
|
345
|
+
> 🚧 **Note**: The mocking features are currently under development
|
|
346
|
+
|
|
347
|
+
The SDK will include powerful mocking capabilities for testing:
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
# 🚧 TODO: Mock feature states for testing
|
|
351
|
+
Client.assume('FEATURE01').true()
|
|
352
|
+
assert switcher.is_on('FEATURE01') == True
|
|
353
|
+
|
|
354
|
+
Client.forget('FEATURE01') # Reset to normal behavior
|
|
355
|
+
|
|
356
|
+
# 🚧 TODO: Mock with metadata
|
|
357
|
+
Client.assume('FEATURE01').false().with_metadata({
|
|
358
|
+
'message': 'Feature is disabled'
|
|
359
|
+
})
|
|
360
|
+
response = switcher.is_on_with_details('FEATURE01')
|
|
361
|
+
assert response.result == False
|
|
362
|
+
assert response.metadata['message'] == 'Feature is disabled'
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Test Mode Configuration
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
# 🚧 TODO: Enable test mode to prevent file locking
|
|
369
|
+
Client.enable_test_mode()
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Configuration Validation
|
|
373
|
+
|
|
374
|
+
Validate your feature flag configuration before deployment:
|
|
375
|
+
|
|
376
|
+
```python
|
|
377
|
+
# Verify that all required switchers are configured
|
|
378
|
+
try:
|
|
379
|
+
Client.check_switchers(['FEATURE_LOGIN', 'FEATURE_DASHBOARD', 'FEATURE_PAYMENTS'])
|
|
380
|
+
print("✅ All switchers are properly configured")
|
|
381
|
+
except Exception as e:
|
|
382
|
+
print(f"❌ Configuration error: {e}")
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
This validation helps prevent deployment issues by ensuring all required feature flags are properly set up in your Switcher domain.
|
|
386
|
+
|
|
387
|
+
## Contributing
|
|
388
|
+
We welcome contributions to the Switcher Client SDK for Python! If you have suggestions, improvements, or bug fixes, please follow these steps:
|
|
389
|
+
|
|
390
|
+
1. Fork the repository.
|
|
391
|
+
2. Create a new branch for your feature or bug fix.
|
|
392
|
+
3. Make your changes and commit them with clear messages.
|
|
393
|
+
4. Submit a pull request detailing your changes and the problem they solve.
|
|
394
|
+
|
|
395
|
+
Thank you for helping us improve the Switcher Client SDK!
|
|
396
|
+
|
|
397
|
+
### Requirements
|
|
398
|
+
- Python 3.9 or higher
|
|
399
|
+
- Virtualenv - `pip install virtualenv`
|
|
400
|
+
- Create a virtual environment - `python3 -m venv .venv`
|
|
401
|
+
- Install Pipenv - `pip install pipenv`
|
|
402
|
+
- Check Makefile for all available commands
|