Skip to content

Commit

Permalink
Merge pull request #38 from Flagsmith/release/3.2.0
Browse files Browse the repository at this point in the history
Release 3.2.0
  • Loading branch information
matthewelwell authored Jan 13, 2023
2 parents 1f73405 + 4e3f141 commit 798750c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flagsmith/flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(
retries: Retry = None,
enable_analytics: bool = False,
default_flag_handler: typing.Callable[[str], DefaultFlag] = None,
proxies: typing.Dict[str, str] = None,
):
"""
:param environment_key: The environment key obtained from Flagsmith interface
Expand All @@ -66,11 +67,13 @@ def __init__(
:param default_flag_handler: callable which will be used in the case where
flags cannot be retrieved from the API or a non existent feature is
requested
:param proxies: as per https://requests.readthedocs.io/en/latest/api/#requests.Session.proxies
"""
self.session = requests.Session()
self.session.headers.update(
**{"X-Environment-Key": environment_key}, **(custom_headers or {})
)
self.session.proxies.update(proxies or {})
retries = retries or Retry(total=3, backoff_factor=0.1)

self.api_url = api_url if api_url.endswith("/") else f"{api_url}/"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "flagsmith"
version = "3.1.0"
version = "3.2.0"
description = "Flagsmith Python SDK"
authors = ["Flagsmith <[email protected]>"]
license = "BSD3"
Expand Down
11 changes: 11 additions & 0 deletions tests/test_flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,14 @@ def test_get_identity_segments_with_valid_trait(
def test_local_evaluation_requires_server_key():
with pytest.raises(ValueError):
Flagsmith(environment_key="not-a-server-key", enable_local_evaluation=True)


def test_initialise_flagsmith_with_proxies():
# Given
proxies = {"https": "https://my.proxy.com/proxy-me"}

# When
flagsmith = Flagsmith(environment_key="test-key", proxies=proxies)

# Then
assert flagsmith.session.proxies == proxies

0 comments on commit 798750c

Please sign in to comment.