Skip to main content

Optional value pattern for python

Project description

py-optional

Coverage Status Coverage Status

Getting started

See Documentation for details.

Features

  • Poetry (virtual environment and publish to PyPi, all with one tool)
  • black (linting/formatter)
  • autoflake (removing unused packages)
  • isort (dependency organization)
  • mypy (static type checking)
  • pytest (including test coverage)
  • pre-commit (hooks on commit)
  • GitHub Actions for CI/CD
  • mkdocs for documentation (with material theme)

Installing py-optional

Install the latest release:

pip install py-optional

Or you can clone py-optional and get started locally

# ensure you have Poetry installed
pip install --user poetry

# install all dependencies (including dev)
poetry install

# develop!

Example Usage

import py-optional

# do stuff

Only Python 3.8+ is supported as required by the black, pydantic packages

Publishing to Pypi

Poetry's documentation

Note that it is recommended to use API tokens when uploading packages to PyPI.

Once you have created a new token, you can tell Poetry to use it:

https://python-poetry.org/docs/repositories/#configuring-credentials

We do this using GitHub Actions' Workflows and Repository Secrets!

Repo Secrets

Go to your repo settings and add a PYPI_TOKEN environment variable:

Github Actions setup of Poetry token environment variable

Inspect the GitHub Actions Publish Workflows

name: Publish

on:
  release:
    types:
      - created

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      ...
      ...
      ...
      - name: Publish
        env:
          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
        run: |
          poetry config pypi-token.pypi $PYPI_TOKEN
          bash scripts/publish.sh

That's it!

When you make a release on GitHub, the publish workflow will run and deploy to PyPi! 🚀🎉😎

Contributing Guide

Welcome! 😊👋

Please see the Contributing Guide.

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

py_optional-1.3.3.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

py_optional-1.3.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file py_optional-1.3.3.tar.gz.

File metadata

  • Download URL: py_optional-1.3.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for py_optional-1.3.3.tar.gz
Algorithm Hash digest
SHA256 f822efe2fe2c618fb606896d0b644c5c90c7840d9d33c1b042e7ad6c6a6282fe
MD5 b832b7046afe5f04dbf8cf3ead139681
BLAKE2b-256 5b6ce0403ed447a0564efc183622618f46834e07535d186c51513ded36a0a31c

See more details on using hashes here.

File details

Details for the file py_optional-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: py_optional-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for py_optional-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c1c5e3c8f7b8edbe7b234cb5e7cac77e7ce99728beac3155cdb80b8277ab56b0
MD5 7df30396cf17d426dc5fcb5112d17c41
BLAKE2b-256 b09e7611f967c71c77472e66100f57ffcd39d7fbb958732ae4b93e7558128986

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