Skip to main content

Small wrapper around faker, to make values optional!

Project description


Support Ukraine

Build Status Code style: black Python support versions badge (from pypi)

Small wrapper around faker, to make values optional!

Note that faker added own optional proxy, which however can be used only with callables. This is why in version 2.0.0 we renamed our method to none_or.


>>> from faker import Faker
>>> import optional_faker
>>> fake = Faker()
>>> Faker.seed(1555)
>>> # `fake.none_or` can take any value, and return it, or None.
>>> fake.none_or(fake.pystr())
>>> fake.none_or(fake.pystr())
>>> # or it can take callable, and *args with **kwargs
>>> # that will be passed to this callable.
>>> fake.none_or(fake.pystr, 1, max_chars=10)
>>> fake.none_or(fake.pystr, 1, max_chars=10)
>>> # there is no explicit check is callable a faker part,
>>> # so you can pass anything.
>>> fake.none_or(lambda: "my callable!")
'my callable!'
>>> fake.none_or(lambda: "my callable!")


pip install optional-faker

And then you need to import optional_faker anywhere but before creating Faker instance.

Installing for local developing

git clone
cd optional-faker

Installing poetry

Next we need install poetry with recommended way.

If you use Linux, use command:

curl -sSL | python -

If you use Windows, open PowerShell with admin privileges and use:

(Invoke-WebRequest -Uri -UseBasicParsing).Content | python -

Installing dependencies

poetry install

If something is not clear

You can always write me!


pip install -U optional-faker

For local development

For updating, just re-download repository, if you used git for downloading, just run git pull.


This project was inspired by faker-optional.

This project was generated with python-template.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optional_faker-2.1.0.tar.gz (14.5 kB view hashes)

Uploaded Source

Built Distribution

optional_faker-2.1.0-py3-none-any.whl (14.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page