Skip to main content

Recipes to generate random instances of various types, beyond the scope of random.

Project description

Random Recipes

pypi downloads tests coverage

Recipes to generate random instances of various types, beyond the scope of random.

Python's random implements generators for pseudo-random bytes, integers, and sequences. In random-recipes we collect additional functions to generate random instances of common object types, collection types, and file types that may be useful.

Recipes

Objects

Object Type Function
bool random_bool
bytes random_bytes
decimal.Decimal random_decimal
datetime.date random_date
datetime.datetime random_datetime
float random_float
fractions.Fraction random_fraction
int random_int
str random_str

Collections

Collection Type Function
dict random_dict
collections.abc.Iterable[dict] random_dicts

Files

File Extension Function
.csv random_csv

Installation

Install the library with pip from PyPi: pip install random-recipes


Development

random-recipes is developed by @ipear3. This is a low-commitment project for practicing Python packaging, but it does try to contribute something of value. Suggestions, comments, and contributions are welcome.

This project draws inspiration from more-itertools, a well-designed, simple extension to a Python's itertools.

Packaging & Dependency Management

Get started with development by installing the project with dev and test dependency groups via Poetry: poetry install --with dev

Formatting

We use Black to format our Python code. We enforce black through a pre-commit hook defined in .pre-commit-config.yaml.

Testing

We use pytest for testing, and our tests are located in /tests. We run our tests during the pre-push hook, pytest.

We use coverage for test coverage, and we assert our test coverage is 95%. Test coverage is checked during the pre-push hook, coverage.

Documentation

We use genbadge to generate our tests and coverage badges. Badges are generated during the pre-push hooks genbdage-tests and genbadge-coverage.

Releases, Tagging, and Versioning

Releases are automatically versioned by the poetry project's version in pyproject.toml. Developers are responsible for incrementing the project version manually when they modify source code. If they forget, the pre-push hook, poetry-auto-semver will increment the patch version by 1.

To create a release on GitHub and PyPi, push a commit to the main branch that affects any of the paths:

  • random_recipes/**
  • pyproject.toml
  • poetry.lock

The release action will automatically:

  1. Install the project
  2. Test the project
  3. Assert test coverage is 95%
  4. Build the project for distribution
  5. Create a GitHub release
    1. Autogenerate release notes
    2. Upload distribution files
  6. Publish the project to PyPi

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

random_recipes-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

random_recipes-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file random_recipes-0.1.0.tar.gz.

File metadata

  • Download URL: random_recipes-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure

File hashes

Hashes for random_recipes-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c4c75d1fe7bdbc39d12b1a79b6d5966791242fcd02cbc888f1078b9dd4eacee
MD5 c275e7c0c3f2e0d98460c4f7ed817204
BLAKE2b-256 4440dba76ec7ff7844f8c43d0404bc318d952d464579212f8c27a77670dc60b0

See more details on using hashes here.

File details

Details for the file random_recipes-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: random_recipes-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure

File hashes

Hashes for random_recipes-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a784b2ee8dea922d9f5d0347a8485bf18807d0dae294e15a255103eb96a49ef
MD5 263cf9eb0a22d9afe6a6663b2f0e5a59
BLAKE2b-256 2343679b166688a1343276e2d03286adf5bdc062a2928748a68fa9193302bd61

See more details on using hashes here.

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