Skip to main content

Tools to convert SQLAlchemy models to Pydantic models

Project description

py-optional

Optional value implementation for python.

Test Publish Dependabot Enabled Coverage Package version Python Versions

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.2.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

py_optional-1.2.1-py3-none-any.whl (7.2 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