index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
6,942
growthbook
__init__
null
def __init__(self, value: Dict, ttl: int) -> None: self.value = value self.ttl = ttl self.expires = time() + ttl
(self, value: Dict, ttl: int) -> NoneType
6,943
growthbook
update
null
def update(self, value: Dict): self.value = value self.expires = time() + self.ttl
(self, value: Dict)
6,944
cryptography.hazmat.primitives.ciphers.base
Cipher
null
class Cipher(typing.Generic[Mode]): def __init__( self, algorithm: CipherAlgorithm, mode: Mode, backend: typing.Any = None, ) -> None: if not isinstance(algorithm, CipherAlgorithm): raise TypeError("Expected interface of CipherAlgorithm.") if mode is ...
(algorithm: 'CipherAlgorithm', mode: 'Mode', backend: 'typing.Any' = None) -> 'None'
6,945
cryptography.hazmat.primitives.ciphers.base
__init__
null
def __init__( self, algorithm: CipherAlgorithm, mode: Mode, backend: typing.Any = None, ) -> None: if not isinstance(algorithm, CipherAlgorithm): raise TypeError("Expected interface of CipherAlgorithm.") if mode is not None: # mypy needs this assert to narrow the type from our ge...
(self, algorithm: cryptography.hazmat.primitives._cipheralgorithm.CipherAlgorithm, mode: +Mode, backend: Optional[Any] = None) -> NoneType
6,946
cryptography.hazmat.primitives.ciphers.base
_wrap_ctx
null
def _wrap_ctx( self, ctx: _BackendCipherContext, encrypt: bool ) -> AEADEncryptionContext | AEADDecryptionContext | CipherContext: if isinstance(self.mode, modes.ModeWithAuthenticationTag): if encrypt: return _AEADEncryptionContext(ctx) else: return _AEADDecryptionContext...
(self, ctx: '_BackendCipherContext', encrypt: 'bool') -> 'AEADEncryptionContext | AEADDecryptionContext | CipherContext'
6,947
cryptography.hazmat.primitives.ciphers.base
decryptor
null
def decryptor(self): from cryptography.hazmat.backends.openssl.backend import backend ctx = backend.create_symmetric_decryption_ctx( self.algorithm, self.mode ) return self._wrap_ctx(ctx, encrypt=False)
(self)
6,948
cryptography.hazmat.primitives.ciphers.base
encryptor
null
def encryptor(self): if isinstance(self.mode, modes.ModeWithAuthenticationTag): if self.mode.tag is not None: raise ValueError( "Authentication tag must be None when encrypting." ) from cryptography.hazmat.backends.openssl.backend import backend ctx = backend....
(self)
6,949
growthbook
Experiment
null
class Experiment(object): def __init__( self, key: str, variations: list, weights: List[float] = None, active: bool = True, status: str = "running", coverage: int = None, condition: dict = None, namespace: Tuple[str, float, float] = None, ...
(key: str, variations: list, weights: List[float] = None, active: bool = True, status: str = 'running', coverage: int = None, condition: dict = None, namespace: Tuple[str, float, float] = None, url: str = '', include=None, groups: list = None, force: int = None, hashAttribute: str = 'id', fallbackAttribute: str = None,...
6,950
growthbook
__init__
null
def __init__( self, key: str, variations: list, weights: List[float] = None, active: bool = True, status: str = "running", coverage: int = None, condition: dict = None, namespace: Tuple[str, float, float] = None, url: str = "", include=None, groups: list = None, force...
(self, key: str, variations: list, weights: Optional[List[float]] = None, active: bool = True, status: str = 'running', coverage: Optional[int] = None, condition: Optional[dict] = None, namespace: Optional[Tuple[str, float, float]] = None, url: str = '', include=None, groups: Optional[list] = None, force: Optional[int]...
6,951
growthbook
to_dict
null
def to_dict(self): obj = { "key": self.key, "variations": self.variations, "weights": self.weights, "active": self.active, "coverage": self.coverage or 1, "condition": self.condition, "namespace": self.namespace, "force": self.force, "hashAttri...
(self)
6,952
growthbook
update
null
def update(self, data: dict) -> None: weights = data.get("weights", None) status = data.get("status", None) coverage = data.get("coverage", None) url = data.get("url", None) groups = data.get("groups", None) force = data.get("force", None) if weights is not None: self.weights = weigh...
(self, data: dict) -> NoneType
6,953
growthbook
Feature
null
class Feature(object): def __init__(self, defaultValue=None, rules: list = []) -> None: self.defaultValue = defaultValue self.rules: List[FeatureRule] = [] for rule in rules: if isinstance(rule, FeatureRule): self.rules.append(rule) else: ...
(defaultValue=None, rules: list = []) -> None
6,954
growthbook
__init__
null
def __init__(self, defaultValue=None, rules: list = []) -> None: self.defaultValue = defaultValue self.rules: List[FeatureRule] = [] for rule in rules: if isinstance(rule, FeatureRule): self.rules.append(rule) else: self.rules.append(FeatureRule( id=ru...
(self, defaultValue=None, rules: list = []) -> NoneType
6,955
growthbook
to_dict
null
def to_dict(self) -> dict: return { "defaultValue": self.defaultValue, "rules": [rule.to_dict() for rule in self.rules], }
(self) -> dict
6,956
growthbook
FeatureRepository
null
class FeatureRepository(object): def __init__(self) -> None: self.cache: AbstractFeatureCache = InMemoryFeatureCache() self.http: Optional[PoolManager] = None def set_cache(self, cache: AbstractFeatureCache) -> None: self.cache = cache def clear_cache(self): self.cache.clea...
() -> None
6,957
growthbook
__init__
null
def __init__(self) -> None: self.cache: AbstractFeatureCache = InMemoryFeatureCache() self.http: Optional[PoolManager] = None
(self) -> NoneType
6,958
growthbook
_fetch_and_decode
null
def _fetch_and_decode(self, api_host: str, client_key: str) -> Optional[Dict]: try: r = self._get(self._get_features_url(api_host, client_key)) if r.status >= 400: logger.warning( "Failed to fetch features, received status code %d", r.status ) retu...
(self, api_host: str, client_key: str) -> Optional[Dict]
6,959
growthbook
_fetch_features
null
def _fetch_features( self, api_host: str, client_key: str, decryption_key: str = "" ) -> Optional[Dict]: decoded = self._fetch_and_decode(api_host, client_key) if not decoded: return None if "encryptedFeatures" in decoded: if not decryption_key: raise ValueError("Must specify...
(self, api_host: str, client_key: str, decryption_key: str = '') -> Optional[Dict]
6,960
growthbook
_get
null
def _get(self, url: str): self.http = self.http or PoolManager() return self.http.request("GET", url)
(self, url: str)
6,961
growthbook
_get_features_url
null
@staticmethod def _get_features_url(api_host: str, client_key: str) -> str: api_host = (api_host or "https://cdn.growthbook.io").rstrip("/") return api_host + "/api/features/" + client_key
(api_host: str, client_key: str) -> str
6,962
growthbook
clear_cache
null
def clear_cache(self): self.cache.clear()
(self)
6,963
growthbook
load_features
null
def load_features( self, api_host: str, client_key: str, decryption_key: str = "", ttl: int = 60 ) -> Optional[Dict]: key = api_host + "::" + client_key cached = self.cache.get(key) if not cached: res = self._fetch_features(api_host, client_key, decryption_key) if res is not None: ...
(self, api_host: str, client_key: str, decryption_key: str = '', ttl: int = 60) -> Optional[Dict]
6,964
growthbook
set_cache
null
def set_cache(self, cache: AbstractFeatureCache) -> None: self.cache = cache
(self, cache: growthbook.AbstractFeatureCache) -> NoneType
6,965
growthbook
FeatureResult
null
class FeatureResult(object): def __init__( self, value, source: str, experiment: Experiment = None, experimentResult: Result = None, ruleId: str = None, ) -> None: self.value = value self.source = source self.ruleId = ruleId self.ex...
(value, source: str, experiment: growthbook.Experiment = None, experimentResult: growthbook.Result = None, ruleId: str = None) -> None
6,966
growthbook
__init__
null
def __init__( self, value, source: str, experiment: Experiment = None, experimentResult: Result = None, ruleId: str = None, ) -> None: self.value = value self.source = source self.ruleId = ruleId self.experiment = experiment self.experimentResult = experimentResult self.o...
(self, value, source: str, experiment: Optional[growthbook.Experiment] = None, experimentResult: Optional[growthbook.Result] = None, ruleId: Optional[str] = None) -> NoneType
6,967
growthbook
to_dict
null
def to_dict(self) -> dict: data = { "value": self.value, "source": self.source, "on": self.on, "off": self.off, } if self.ruleId: data["ruleId"] = self.ruleId if self.experiment: data["experiment"] = self.experiment.to_dict() if self.experimentResult: ...
(self) -> dict
6,968
growthbook
FeatureRule
null
class FeatureRule(object): def __init__( self, id: str = None, key: str = "", variations: list = None, weights: List[float] = None, coverage: int = None, condition: dict = None, namespace: Tuple[str, float, float] = None, force=None, ha...
(id: str = None, key: str = '', variations: list = None, weights: List[float] = None, coverage: int = None, condition: dict = None, namespace: Tuple[str, float, float] = None, force=None, hashAttribute: str = 'id', fallbackAttribute: str = None, hashVersion: int = None, range: Tuple[float, float] = None, ranges: List[T...
6,969
growthbook
__init__
null
def __init__( self, id: str = None, key: str = "", variations: list = None, weights: List[float] = None, coverage: int = None, condition: dict = None, namespace: Tuple[str, float, float] = None, force=None, hashAttribute: str = "id", fallbackAttribute: str = None, hashVer...
(self, id: Optional[str] = None, key: str = '', variations: Optional[list] = None, weights: Optional[List[float]] = None, coverage: Optional[int] = None, condition: Optional[dict] = None, namespace: Optional[Tuple[str, float, float]] = None, force=None, hashAttribute: str = 'id', fallbackAttribute: Optional[str] = None...
6,970
growthbook
to_dict
null
def to_dict(self) -> dict: data: Dict[str, Any] = {} if self.id: data["id"] = self.id if self.key: data["key"] = self.key if self.variations is not None: data["variations"] = self.variations if self.weights is not None: data["weights"] = self.weights if self.cover...
(self) -> dict
6,971
growthbook
Filter
null
class Filter(TypedDict): seed: str ranges: List[Tuple[float, float]] hashVersion: int attribute: str
null
6,972
growthbook
GrowthBook
null
class GrowthBook(object): def __init__( self, enabled: bool = True, attributes: dict = {}, url: str = "", features: dict = {}, qa_mode: bool = False, on_experiment_viewed=None, api_host: str = "", client_key: str = "", decryption_key: s...
(enabled: bool = True, attributes: dict = {}, url: str = '', features: dict = {}, qa_mode: bool = False, on_experiment_viewed=None, api_host: str = '', client_key: str = '', decryption_key: str = '', cache_ttl: int = 60, forced_variations: dict = {}, sticky_bucket_service: growthbook.AbstractStickyBucketService = None,...
6,973
growthbook
__init__
null
def __init__( self, enabled: bool = True, attributes: dict = {}, url: str = "", features: dict = {}, qa_mode: bool = False, on_experiment_viewed=None, api_host: str = "", client_key: str = "", decryption_key: str = "", cache_ttl: int = 60, forced_variations: dict = {}, ...
(self, enabled: bool = True, attributes: dict = {}, url: str = '', features: dict = {}, qa_mode: bool = False, on_experiment_viewed=None, api_host: str = '', client_key: str = '', decryption_key: str = '', cache_ttl: int = 60, forced_variations: dict = {}, sticky_bucket_service: Optional[growthbook.AbstractStickyBucket...
6,974
growthbook
_derive_sticky_bucket_identifier_attributes
null
def _derive_sticky_bucket_identifier_attributes(self) -> List[str]: attributes = set() for key, feature in self._features.items(): for rule in feature.rules: if rule.variations: attributes.add(rule.hashAttribute or "id") if rule.fallbackAttribute: ...
(self) -> List[str]
6,975
growthbook
_eval_feature
null
def _eval_feature(self, key: str, stack: Set[str]) -> FeatureResult: logger.debug("Evaluating feature %s", key) if key not in self._features: logger.warning("Unknown feature %s", key) return FeatureResult(None, "unknownFeature") if key in stack: logger.warning("Cyclic prerequisite de...
(self, key: str, stack: Set[str]) -> growthbook.FeatureResult
6,976
growthbook
_fireSubscriptions
null
def _fireSubscriptions(self, experiment: Experiment, result: Result): prev = self._assigned.get(experiment.key, None) if ( not prev or prev["result"].inExperiment != result.inExperiment or prev["result"].variationId != result.variationId ): self._assigned[experiment.key] = { ...
(self, experiment: growthbook.Experiment, result: growthbook.Result)
6,977
growthbook
_generate_sticky_bucket_assignment_doc
null
def _generate_sticky_bucket_assignment_doc(self, attribute_name: str, attribute_value: str, assignments: dict): key = attribute_name + "||" + attribute_value existing_assignments = self._sticky_bucket_assignment_docs.get(key, {}).get("assignments", {}) new_assignments = {**existing_assignments, **assignment...
(self, attribute_name: str, attribute_value: str, assignments: dict)
6,978
growthbook
_getExperimentResult
null
def _getExperimentResult( self, experiment: Experiment, variationId: int = -1, hashUsed: bool = False, featureId: str = None, bucket: float = None, stickyBucketUsed: bool = False ) -> Result: inExperiment = True if variationId < 0 or variationId > len(experiment.variations) - 1: ...
(self, experiment: growthbook.Experiment, variationId: int = -1, hashUsed: bool = False, featureId: Optional[str] = None, bucket: Optional[float] = None, stickyBucketUsed: bool = False) -> growthbook.Result
6,979
growthbook
_getHashValue
null
def _getHashValue(self, attr: str = None, fallbackAttr: str = None) -> Tuple[str, str]: (attr, val) = self._getOrigHashValue(attr, fallbackAttr) return (attr, str(val))
(self, attr: Optional[str] = None, fallbackAttr: Optional[str] = None) -> Tuple[str, str]
6,980
growthbook
_getOrigHashValue
null
def _getOrigHashValue(self, attr: str = None, fallbackAttr: str = None) -> Tuple[str, str]: attr = attr or "id" val = "" if attr in self._attributes: val = self._attributes[attr] or "" elif attr in self._user: val = self._user[attr] or "" # If no match, try fallback if (not val o...
(self, attr: Optional[str] = None, fallbackAttr: Optional[str] = None) -> Tuple[str, str]
6,981
growthbook
_get_sticky_bucket_assignments
null
def _get_sticky_bucket_assignments(self, attr: str = None, fallback: str = None) -> Dict[str, str]: merged: Dict[str, str] = {} _, hashValue = self._getHashValue(attr) key = f"{attr}||{hashValue}" if key in self._sticky_bucket_assignment_docs: merged = self._sticky_bucket_assignment_docs[key].ge...
(self, attr: Optional[str] = None, fallback: Optional[str] = None) -> Dict[str, str]
6,982
growthbook
_get_sticky_bucket_attributes
null
def _get_sticky_bucket_attributes(self) -> dict: attributes: Dict[str, str] = {} if self._using_derived_sticky_bucket_attributes: self.sticky_bucket_identifier_attributes = self._derive_sticky_bucket_identifier_attributes() if not self.sticky_bucket_identifier_attributes: return attributes ...
(self) -> dict
6,983
growthbook
_get_sticky_bucket_experiment_key
null
def _get_sticky_bucket_experiment_key(self, experiment_key: str, bucket_version: int = 0) -> str: return experiment_key + "__" + str(bucket_version)
(self, experiment_key: str, bucket_version: int = 0) -> str
6,984
growthbook
_get_sticky_bucket_variation
null
def _get_sticky_bucket_variation( self, experiment_key: str, bucket_version: int = None, min_bucket_version: int = None, meta: List[VariationMeta] = None, hash_attribute: str = None, fallback_attribute: str = None ) -> dict: bucket_version = bucket_version or 0 min_bucket_version = m...
(self, experiment_key: str, bucket_version: Optional[int] = None, min_bucket_version: Optional[int] = None, meta: Optional[List[growthbook.VariationMeta]] = None, hash_attribute: Optional[str] = None, fallback_attribute: Optional[str] = None) -> dict
6,985
growthbook
_isFilteredOut
null
def _isFilteredOut(self, filters: List[Filter]) -> bool: for filter in filters: (_, hash_value) = self._getHashValue(filter.get("attribute", "id")) if hash_value == "": return False n = gbhash(filter.get("seed", ""), hash_value, filter.get("hashVersion", 2)) if n is None:...
(self, filters: List[growthbook.Filter]) -> bool
6,986
growthbook
_isIncludedInRollout
null
def _isIncludedInRollout( self, seed: str, hashAttribute: str = None, fallbackAttribute: str = None, range: Tuple[float, float] = None, coverage: float = None, hashVersion: int = None, ) -> bool: if coverage is None and range is None: return True (_, hash_value) = self._getHa...
(self, seed: str, hashAttribute: Optional[str] = None, fallbackAttribute: Optional[str] = None, range: Optional[Tuple[float, float]] = None, coverage: Optional[float] = None, hashVersion: Optional[int] = None) -> bool
6,987
growthbook
_is_blocked
null
def _is_blocked( self, assignments: Dict[str, str], experiment_key: str, min_bucket_version: int ) -> bool: if min_bucket_version > 0: for i in range(min_bucket_version): blocked_key = self._get_sticky_bucket_experiment_key(experiment_key, i) if blocked_key in assignm...
(self, assignments: Dict[str, str], experiment_key: str, min_bucket_version: int) -> bool
6,988
growthbook
_run
null
def _run(self, experiment: Experiment, featureId: Optional[str] = None) -> Result: # 1. If experiment has less than 2 variations, return immediately if len(experiment.variations) < 2: logger.warning( "Experiment %s has less than 2 variations, skip", experiment.key ) return se...
(self, experiment: growthbook.Experiment, featureId: Optional[str] = None) -> growthbook.Result
6,989
growthbook
_track
null
def _track(self, experiment: Experiment, result: Result) -> None: if not self._trackingCallback: return None key = ( result.hashAttribute + str(result.hashValue) + experiment.key + str(result.variationId) ) if not self._tracked.get(key): try: s...
(self, experiment: growthbook.Experiment, result: growthbook.Result) -> NoneType
6,990
growthbook
_urlIsValid
null
def _urlIsValid(self, pattern) -> bool: if not self._url: return False try: r = re.compile(pattern) if r.search(self._url): return True pathOnly = re.sub(r"^[^/]*/", "/", re.sub(r"^https?:\/\/", "", self._url)) if r.search(pathOnly): return True ...
(self, pattern) -> bool
6,991
growthbook
destroy
null
def destroy(self) -> None: self._subscriptions.clear() self._tracked.clear() self._assigned.clear() self._trackingCallback = None self._forcedVariations.clear() self._overrides.clear() self._groups.clear() self._attributes.clear() self._features.clear()
(self) -> NoneType
6,992
growthbook
evalFeature
null
def evalFeature(self, key: str) -> FeatureResult: return self.eval_feature(key)
(self, key: str) -> growthbook.FeatureResult
6,993
growthbook
eval_feature
null
def eval_feature(self, key: str) -> FeatureResult: return self._eval_feature(key, set())
(self, key: str) -> growthbook.FeatureResult
6,994
growthbook
eval_prereqs
null
def eval_prereqs(self, parentConditions: List[dict], stack: Set[str]) -> str: for parentCondition in parentConditions: parentRes = self._eval_feature(parentCondition.get("id", None), stack) if parentRes.source == "cyclicPrerequisite": return "cyclic" if not evalCondition({'value'...
(self, parentConditions: List[dict], stack: Set[str]) -> str
6,995
growthbook
getAllResults
null
def getAllResults(self): return self.get_all_results()
(self)
6,996
growthbook
getAttributes
null
def getAttributes(self) -> dict: return self.get_attributes()
(self) -> dict
6,997
growthbook
getFeatureValue
null
def getFeatureValue(self, key: str, fallback): return self.get_feature_value(key, fallback)
(self, key: str, fallback)
6,998
growthbook
getFeatures
null
def getFeatures(self) -> Dict[str, Feature]: return self.get_features()
(self) -> Dict[str, growthbook.Feature]
6,999
growthbook
get_all_results
null
def get_all_results(self): return self._assigned.copy()
(self)
7,000
growthbook
get_attributes
null
def get_attributes(self) -> dict: return self._attributes
(self) -> dict
7,001
growthbook
get_feature_value
null
def get_feature_value(self, key: str, fallback): res = self.evalFeature(key) return res.value if res.value is not None else fallback
(self, key: str, fallback)
7,002
growthbook
get_features
null
def get_features(self) -> Dict[str, Feature]: return self._features
(self) -> Dict[str, growthbook.Feature]
7,003
growthbook
isOff
null
def isOff(self, key: str) -> bool: return self.is_off(key)
(self, key: str) -> bool
7,004
growthbook
isOn
null
def isOn(self, key: str) -> bool: return self.is_on(key)
(self, key: str) -> bool
7,005
growthbook
is_off
null
def is_off(self, key: str) -> bool: return self.evalFeature(key).off
(self, key: str) -> bool
7,006
growthbook
is_on
null
def is_on(self, key: str) -> bool: return self.evalFeature(key).on
(self, key: str) -> bool
7,007
growthbook
load_features
null
def load_features(self) -> None: if not self._client_key: raise ValueError("Must specify `client_key` to refresh features") features = feature_repo.load_features( self._api_host, self._client_key, self._decryption_key, self._cache_ttl ) if features is not None: self.setFeatures(f...
(self) -> NoneType
7,008
growthbook
refresh_sticky_buckets
null
def refresh_sticky_buckets(self, force: bool = False) -> None: if not self.sticky_bucket_service: return attributes = self._get_sticky_bucket_attributes() if not force and attributes == self._sticky_bucket_attributes: logger.debug("Skipping refresh of sticky bucket assignments, no changes") ...
(self, force: bool = False) -> NoneType
7,009
growthbook
run
null
def run(self, experiment: Experiment) -> Result: result = self._run(experiment) self._fireSubscriptions(experiment, result) return result
(self, experiment: growthbook.Experiment) -> growthbook.Result
7,010
growthbook
setAttributes
null
def setAttributes(self, attributes: dict) -> None: return self.set_attributes(attributes)
(self, attributes: dict) -> NoneType
7,011
growthbook
setFeatures
null
def setFeatures(self, features: dict) -> None: return self.set_features(features)
(self, features: dict) -> NoneType
7,012
growthbook
set_attributes
null
def set_attributes(self, attributes: dict) -> None: self._attributes = attributes self.refresh_sticky_buckets()
(self, attributes: dict) -> NoneType
7,013
growthbook
set_features
null
def set_features(self, features: dict) -> None: self._features = {} for key, feature in features.items(): if isinstance(feature, Feature): self._features[key] = feature else: self._features[key] = Feature( rules=feature.get("rules", []), de...
(self, features: dict) -> NoneType
7,014
growthbook
subscribe
null
def subscribe(self, callback): self._subscriptions.add(callback) return lambda: self._subscriptions.remove(callback)
(self, callback)
7,015
growthbook
InMemoryFeatureCache
null
class InMemoryFeatureCache(AbstractFeatureCache): def __init__(self) -> None: self.cache: Dict[str, CacheEntry] = {} def get(self, key: str) -> Optional[Dict]: if key in self.cache: entry = self.cache[key] if entry.expires >= time(): return entry.value ...
() -> None
7,016
growthbook
__init__
null
def __init__(self) -> None: self.cache: Dict[str, CacheEntry] = {}
(self) -> NoneType
7,017
growthbook
clear
null
def clear(self) -> None: self.cache.clear()
(self) -> NoneType
7,018
growthbook
get
null
def get(self, key: str) -> Optional[Dict]: if key in self.cache: entry = self.cache[key] if entry.expires >= time(): return entry.value return None
(self, key: str) -> Optional[Dict]
7,019
growthbook
set
null
def set(self, key: str, value: Dict, ttl: int) -> None: if key in self.cache: self.cache[key].update(value) self.cache[key] = CacheEntry(value, ttl)
(self, key: str, value: Dict, ttl: int) -> NoneType
7,020
growthbook
InMemoryStickyBucketService
null
class InMemoryStickyBucketService(AbstractStickyBucketService): def __init__(self) -> None: self.docs: Dict[str, Dict] = {} def get_assignments(self, attributeName: str, attributeValue: str) -> Optional[Dict]: return self.docs.get(self.get_key(attributeName, attributeValue), None) def save...
() -> None
7,021
growthbook
__init__
null
def __init__(self) -> None: self.docs: Dict[str, Dict] = {}
(self) -> NoneType
7,022
growthbook
destroy
null
def destroy(self) -> None: self.docs.clear()
(self) -> NoneType
7,024
growthbook
get_assignments
null
def get_assignments(self, attributeName: str, attributeValue: str) -> Optional[Dict]: return self.docs.get(self.get_key(attributeName, attributeValue), None)
(self, attributeName: str, attributeValue: str) -> Optional[Dict]
7,026
growthbook
save_assignments
null
def save_assignments(self, doc: Dict) -> None: self.docs[self.get_key(doc["attributeName"], doc["attributeValue"])] = doc
(self, doc: Dict) -> NoneType
7,027
urllib3.poolmanager
PoolManager
Allows for arbitrary requests while transparently keeping track of necessary connection pools for you. :param num_pools: Number of connection pools to cache before discarding the least recently used pool. :param headers: Headers to include with all requests, unless other heade...
class PoolManager(RequestMethods): """ Allows for arbitrary requests while transparently keeping track of necessary connection pools for you. :param num_pools: Number of connection pools to cache before discarding the least recently used pool. :param headers: Headers to inc...
(num_pools: 'int' = 10, headers: 'typing.Mapping[str, str] | None' = None, **connection_pool_kw: 'typing.Any') -> 'None'
7,028
urllib3.poolmanager
__enter__
null
def __enter__(self: _SelfT) -> _SelfT: return self
(self: ~_SelfT) -> ~_SelfT
7,029
urllib3.poolmanager
__exit__
null
def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> Literal[False]: self.clear() # Return False to re-raise any potential exceptions return False
(self, exc_type: 'type[BaseException] | None', exc_val: 'BaseException | None', exc_tb: 'TracebackType | None') -> 'Literal[False]'
7,030
urllib3.poolmanager
__init__
null
def __init__( self, num_pools: int = 10, headers: typing.Mapping[str, str] | None = None, **connection_pool_kw: typing.Any, ) -> None: super().__init__(headers) self.connection_pool_kw = connection_pool_kw self.pools: RecentlyUsedContainer[PoolKey, HTTPConnectionPool] self.pools = Recent...
(self, num_pools: int = 10, headers: Optional[Mapping[str, str]] = None, **connection_pool_kw: Any) -> NoneType
7,031
urllib3.poolmanager
_merge_pool_kwargs
Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary.
def _merge_pool_kwargs( self, override: dict[str, typing.Any] | None ) -> dict[str, typing.Any]: """ Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` ar...
(self, override: dict[str, typing.Any] | None) -> dict[str, typing.Any]
7,032
urllib3.poolmanager
_new_pool
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. This method is used to actually create the connect...
def _new_pool( self, scheme: str, host: str, port: int, request_context: dict[str, typing.Any] | None = None, ) -> HTTPConnectionPool: """ Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_...
(self, scheme: str, host: str, port: int, request_context: Optional[dict[str, Any]] = None) -> urllib3.connectionpool.HTTPConnectionPool
7,033
urllib3.poolmanager
_proxy_requires_url_absolute_form
Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel.
def _proxy_requires_url_absolute_form(self, parsed_url: Url) -> bool: """ Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel. """ if self.proxy is None: return False return not connection_re...
(self, parsed_url: urllib3.util.url.Url) -> bool
7,034
urllib3.poolmanager
clear
Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion.
def clear(self) -> None: """ Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion. """ self.pools.clear()
(self) -> NoneType
7,035
urllib3.poolmanager
connection_from_context
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable.
def connection_from_context( self, request_context: dict[str, typing.Any] ) -> HTTPConnectionPool: """ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` i...
(self, request_context: dict[str, typing.Any]) -> urllib3.connectionpool.HTTPConnectionPool
7,036
urllib3.poolmanager
connection_from_host
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_...
def connection_from_host( self, host: str | None, port: int | None = None, scheme: str | None = "http", pool_kwargs: dict[str, typing.Any] | None = None, ) -> HTTPConnectionPool: """ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn...
(self, host: str | None, port: Optional[int] = None, scheme: str | None = 'http', pool_kwargs: Optional[dict[str, Any]] = None) -> urllib3.connectionpool.HTTPConnectionPool
7,037
urllib3.poolmanager
connection_from_pool_key
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ``port`` fields.
def connection_from_pool_key( self, pool_key: PoolKey, request_context: dict[str, typing.Any] ) -> HTTPConnectionPool: """ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it mu...
(self, pool_key: urllib3.poolmanager.PoolKey, request_context: dict[str, typing.Any]) -> urllib3.connectionpool.HTTPConnectionPool
7,038
urllib3.poolmanager
connection_from_url
Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` is provided, it is ...
def connection_from_url( self, url: str, pool_kwargs: dict[str, typing.Any] | None = None ) -> HTTPConnectionPool: """ Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to init...
(self, url: str, pool_kwargs: Optional[dict[str, Any]] = None) -> urllib3.connectionpool.HTTPConnectionPool
7,039
urllib3._request_methods
request
Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used. This is a convenience method that requires the least amount of manual effort. It can be used in most situations, while still having the option to drop down to more spe...
def request( self, method: str, url: str, body: _TYPE_BODY | None = None, fields: _TYPE_FIELDS | None = None, headers: typing.Mapping[str, str] | None = None, json: typing.Any | None = None, **urlopen_kw: typing.Any, ) -> BaseHTTPResponse: """ Make a request using :meth:`urlopen`...
(self, method: str, url: str, body: Union[bytes, IO[Any], Iterable[bytes], str, NoneType] = None, fields: Union[Sequence[Union[Tuple[str, Union[str, bytes, Tuple[str, Union[str, bytes]], Tuple[str, Union[str, bytes], str]]], urllib3.fields.RequestField]], Mapping[str, Union[str, bytes, Tuple[str, Union[str, bytes]], Tu...
7,040
urllib3._request_methods
request_encode_body
Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc. When ``encode_multipart=True`` (default), then :func:`urllib3.encode_multipart_formdata` is used to encode the payload with the appropria...
def request_encode_body( self, method: str, url: str, fields: _TYPE_FIELDS | None = None, headers: typing.Mapping[str, str] | None = None, encode_multipart: bool = True, multipart_boundary: str | None = None, **urlopen_kw: str, ) -> BaseHTTPResponse: """ Make a request using :met...
(self, method: str, url: str, fields: Union[Sequence[Union[Tuple[str, Union[str, bytes, Tuple[str, Union[str, bytes]], Tuple[str, Union[str, bytes], str]]], urllib3.fields.RequestField]], Mapping[str, Union[str, bytes, Tuple[str, Union[str, bytes]], Tuple[str, Union[str, bytes], str]]], NoneType] = None, headers: Optio...
7,041
urllib3._request_methods
request_encode_url
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. :param method: HTTP request method (such as GET, POST, PUT, etc.) :param url: The URL to perform the request on. ...
def request_encode_url( self, method: str, url: str, fields: _TYPE_ENCODE_URL_FIELDS | None = None, headers: typing.Mapping[str, str] | None = None, **urlopen_kw: str, ) -> BaseHTTPResponse: """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is usef...
(self, method: str, url: str, fields: Union[Sequence[Tuple[str, Union[str, bytes]]], Mapping[str, Union[str, bytes]], NoneType] = None, headers: Optional[Mapping[str, str]] = None, **urlopen_kw: str) -> urllib3.response.BaseHTTPResponse
7,042
urllib3.poolmanager
urlopen
Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate :class:`urllib3.connectionpool.ConnectionPool` can be chosen fo...
def urlopen( # type: ignore[override] self, method: str, url: str, redirect: bool = True, **kw: typing.Any ) -> BaseHTTPResponse: """ Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url``...
(self, method: str, url: str, redirect: bool = True, **kw: Any) -> urllib3.response.BaseHTTPResponse
7,043
growthbook
Result
null
class Result(object): def __init__( self, variationId: int, inExperiment: bool, value, hashUsed: bool, hashAttribute: str, hashValue: str, featureId: Optional[str], meta: VariationMeta = None, bucket: float = None, stickyBucketU...
(variationId: int, inExperiment: bool, value, hashUsed: bool, hashAttribute: str, hashValue: str, featureId: Optional[str], meta: growthbook.VariationMeta = None, bucket: float = None, stickyBucketUsed: bool = False) -> None