faker.proxy

Module Contents

Classes

Faker

Proxy class capable of supporting multiple locales

UniqueProxy

OptionalProxy

Return either a fake value or None, with a customizable probability.

Attributes

_UNIQUE_ATTEMPTS

RetType

faker.proxy._UNIQUE_ATTEMPTS = 1000
faker.proxy.RetType
class faker.proxy.Faker(locale: Optional[Union[str, Sequence[str], Dict[str, Union[int, float]]]] = None, providers: Optional[List[str]] = None, generator: Optional[faker.generator.Generator] = None, includes: Optional[List[str]] = None, use_weighting: bool = True, **config: Any)

Proxy class capable of supporting multiple locales

property unique: UniqueProxy
property optional: OptionalProxy
property random: random.Random

Proxies random getter calls

In single locale mode, this will be proxied to the random getter of the only internal Generator object. Subclasses will have to implement desired behavior in multiple locale mode.

property locales: List[str]
property weights: Optional[List[Union[int, float]]]
property factories: List[faker.generator.Generator]
cache_pattern: Pattern
generator_attrs
__dir__()

Default dir() implementation.

__getitem__(locale: str) faker.generator.Generator
__getattribute__(attr: str) Any

Handles the “attribute resolution” behavior for declared members of this proxy class

The class method seed cannot be called from an instance.

Parameters

attr – attribute name

Returns

the appropriate attribute

__getattr__(attr: str) Any

Handles cache access and proxying behavior

Parameters

attr – attribute name

Returns

the appropriate attribute

__deepcopy__(memodict: Dict = {}) Faker
__setstate__(state: Any) None
_select_factory(method_name: str) faker.factory.Factory

Returns a random factory that supports the provider method

Parameters

method_name – Name of provider method

Returns

A factory that supports the provider method

_select_factory_distribution(factories, weights)
_select_factory_choice(factories)
_map_provider_method(method_name: str) Tuple[List[faker.factory.Factory], Optional[List[float]]]

Creates a 2-tuple of factories and weights for the given provider method name

The first element of the tuple contains a list of compatible factories. The second element of the tuple contains a list of distribution weights.

Parameters

method_name – Name of provider method

Returns

2-tuple (factories, weights)

classmethod seed(seed: Optional[faker.typing.SeedType] = None) None

Hashables the shared random.Random object across all factories

Parameters

seed – seed value

seed_instance(seed: Optional[faker.typing.SeedType] = None) None

Creates and seeds a new random.Random object for each factory

Parameters

seed – seed value

seed_locale(locale: str, seed: Optional[faker.typing.SeedType] = None) None

Creates and seeds a new random.Random object for the factory of the specified locale

Parameters
  • locale – locale string

  • seed – seed value

items() List[Tuple[str, faker.generator.Generator]]
class faker.proxy.UniqueProxy(proxy: Faker)
clear() None
__getattr__(name: str) Any
__getstate__()

Helper for pickle.

__setstate__(state)
_wrap(name: str, function: Callable) Callable
class faker.proxy.OptionalProxy(proxy: Faker)

Return either a fake value or None, with a customizable probability.

__getattr__(name: str) Any
__getstate__()

Helper for pickle.

__setstate__(state)
_wrap(name: str, function: Callable[Ellipsis, RetType]) Callable[Ellipsis, Optional[RetType]]