### Install dependencies and activate virtualenv Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Installs project dependencies using poetry and activates the virtual environment. ```shell poetry install eval $(poetry env activate) ``` -------------------------------- ### Install optional dependencies Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Installs optional dependencies for specific features like Redis, Consul, DynamoDB, or test-filesource. ```shell poetry install --extras "redis consul dynamodb test-filesource" poetry install -E redis -E consul -E dynamodb -E test-filesource poetry install --all-extras ``` -------------------------------- ### LDClient Constructor with Config Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Example of how to instantiate LDClient with a Config object, specifying the SDK key and other configuration options. ```python LDClient(Config(sdk_key = "my-sdk-key", [any other config options])) ``` -------------------------------- ### HTTPConfig for Network Behavior Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Example of using HTTPConfig to customize network behavior, such as setting a connect timeout. ```python Config(sdk_key = "my-sdk-key", http = HTTPConfig(connect_timeout = 10)) ``` -------------------------------- ### Type Hint for Private Attributes Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Example of how to use type hints for private attributes in Python using a mypy-compatible comment. ```python self._some_attribute = None # type: Optional[int] ``` -------------------------------- ### Build and view docs Source: https://github.com/launchdarkly/python-server-sdk/blob/main/docs/README.md Commands to build and view the generated documentation locally. ```bash make html view docs/build/html/index.html ``` -------------------------------- ### Build documentation locally Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Builds the project documentation locally to preview changes. ```shell make docs ``` -------------------------------- ### Sample Expected Output Source: https://github.com/launchdarkly/python-server-sdk/blob/main/PROVENANCE.md A sample of the expected output when verifying SDK package provenance using the GitHub CLI. ```text Loaded digest sha256:... for file://launchdarkly_server_sdk-9.15.0-py3-none-any.whl Loaded 1 attestation from GitHub API The following policy criteria will be enforced: - Predicate type must match:................ https://slsa.dev/provenance/v1 - Source Repository Owner URI must match:... https://github.com/launchdarkly - Subject Alternative Name must match regex: (?i)^https://github.com/launchdarkly/ - OIDC Issuer must match:................... https://token.actions.githubusercontent.com ✓ Verification succeeded! The following 1 attestation matched the policy criteria - Attestation #1 - Build repo:..... launchdarkly/python-server-sdk - Build workflow:. .github/workflows/release-please.yml - Signer repo:.... launchdarkly/python-server-sdk - Signer workflow: .github/workflows/release-please.yml ``` -------------------------------- ### Run all unit tests including database integrations Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Runs all unit tests, including database integrations. Requires local instances of Consul, DynamoDB, and Redis. ```shell make test-all ``` -------------------------------- ### Run unit tests Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Runs all unit tests, excluding database integrations. ```shell make test ``` -------------------------------- ### Contexts vs Users Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Explanation of how contexts evolve from users and can be represented as dictionaries or Context objects. ```python For all SDK methods that took a user parameter in the form of a `dict`, you can now pass a `Context` instead. You can still pass a `dict` containing user properties, in which case the SDK will convert it to a `Context` transparently; however, `Context` is preferable if you value efficiency since there is some overhead to this conversion. ``` -------------------------------- ### Set SDK Version Source: https://github.com/launchdarkly/python-server-sdk/blob/main/PROVENANCE.md Sets the version of the SDK to be verified. ```shell # Set the version of the SDK to verify SDK_VERSION=9.15.1 ``` -------------------------------- ### Redis Feature Store Configuration Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Introduction of the `redis_opts` parameter for Redis feature and Big Segment stores. ```python A new `redis_opts` parameter is available when configuring a [Redis feature or Big Segment store](https://launchdarkly-python-sdk.readthedocs.io/en/latest/api-integrations.html#ldclient.integrations.Redis). This parameter will be passed through to the underlying redis driver, allowing for greater configurability. (Thanks, [danie1k](https://github.com/launchdarkly/python-server-sdk/pull/170)!) ``` -------------------------------- ### Verify SDK Package Provenance Source: https://github.com/launchdarkly/python-server-sdk/blob/main/PROVENANCE.md Downloads the specified SDK package from PyPI and verifies its provenance using the GitHub CLI. ```shell # Download package from PyPI $ pip download --only-binary=:all: launchdarkly-server-sdk==${SDK_VERSION} # Verify provenance using the GitHub CLI $ gh attestation verify launchdarkly_server_sdk-${SDK_VERSION}-py3-none-any.whl --owner launchdarkly ``` -------------------------------- ### Run linter Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CONTRIBUTING.md Runs the mypy type checker to verify type hints and identify potential code problems. ```shell make lint ``` -------------------------------- ### HTTP Proxy Configuration Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md The new `Config` parameter `http_proxy` allows you to specify a proxy server programmatically rather than by using environment variables. ```python http_proxy ``` -------------------------------- ### all_flags_state method for front-end data Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md The `all_flags_state()` method should be used instead of `all_flags()` when passing flag data to the front end for use with the JavaScript SDK, as it preserves necessary metadata. ```python LDClient.all_flags_state() ``` -------------------------------- ### TestData Flag Builder Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Extension of TestData flag builder methods to support context-related options. ```python The `TestData` flag builder methods have been extended to support now context-related options, such as matching a key for a specific context type other than "user". ``` -------------------------------- ### Tracking Events Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Added support for upcoming LaunchDarkly experimentation features. See `LDClient.track()`. ```python LDClient.track() ``` -------------------------------- ### TestData for Programmatic Feature Flag Injection Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md Description of TestData for injecting feature flag data programmatically for testing. ```python `TestData`, in the new module `ldclient.integrations.test_data`, is a new way to inject feature flag data programmatically into the SDK for testing—either with fixed values for each flag, or with targets and/or rules that can return different values for different users. Unlike the file data source, this mechanism does not use any external resources, only the data that your test code has provided. ``` -------------------------------- ### New variation_detail method Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md The `variation_detail` method allows evaluation of a feature flag with more information about how the value was calculated, returned in an `EvaluationDetail` object. ```python LDClient.variation_detail(key, default, user) ``` -------------------------------- ### Diagnostic Data Configuration Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md The SDK now periodically sends diagnostic data to LaunchDarkly. This behavior can be disabled with the `diagnostic_opt_out` option or configured with `diagnostic_recording_interval`. ```python diagnostic_opt_out diagnostic_recording_interval ``` -------------------------------- ### Client-side only flags Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md The `all_flags_state()` method allows selecting only client-side-enabled flags by using the option `client_side_only=True`. ```python LDClient.all_flags_state(client_side_only=True) ``` -------------------------------- ### Suppressing backoff error messages Source: https://github.com/launchdarkly/python-server-sdk/blob/main/CHANGELOG.md To suppress the default connection failure/reconnection attempt messages from the LaunchDarkly client when using streaming mode, set `logging.getLogger('backoff').propagate` to `True`. ```python logging.getLogger('backoff').propagate = True ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.