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 hashes)

Uploaded Source

Built Distribution

random_recipes-0.1.0-py3-none-any.whl (6.4 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