Skip to main content

pypi github

enum-actions

For easy selection command-line selection of an enum.Enum variant with argparse.Actions.

Use it like this:

>>> from enum_actions import enum_action
>>> from argparse import ArgumentParser
>>> import enum

>>> class MyEnum(enum.Enum):
...     A = 1
...     B = 2

>>> parser = ArgumentParser()
>>> _ = parser.add_argument("-e", "--enum", action=enum_action(MyEnum), default="a", help="pick a variant") # create an action for your enum
>>> args = parser.parse_args() # there will be an instance of MyEnum in the args object

Features

Choices are handled transparently

foo.py --help

usage: foo.py [-h] [-e {a,b}]

optional arguments:
  -h, --help            show this help message and exit
  -e {a,b}, --enum {a,b}
                        pick a variant (default: b)

Defaults are handled transparently

Having a default string or enum will both work

parser.add_argument("--enum", action=enum_action(MyEnum), default="a")
parser.add_argument("--enum", action=enum_action(MyEnum), default=MyEnum.A)

Metadata

Release files for enum-actions 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enum-actions 0.1.2
File Size Uploaded Provenance
enum-actions-0.1.2.tar.gz 2.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for enum-actions 0.1.2
File Interpreter ABI Platform
enum_actions-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 5.3 kB

Release files / enum-actions-0.1.2.tar.gz

Download URL enum-actions-0.1.2.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6e8b03cc4a4f040b397b5ba8d8ecf2802b7c74bf356d2bb49669c548e5697f3a
BLAKE2b-256 checksum
How to use checksums
00eec8982025d7ad0b0d5d2f647af5138050649df46ae799829926b039a2046a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.10 Linux/5.10.60.1-microsoft-standard-WSL2

Release files / enum_actions-0.1.2-py3-none-any.whl

Download URL enum_actions-0.1.2-py3-none-any.whl
Size 2.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25bcf6d93e32be20856809bffcab9384e2c0c82cbe7e69a819a152834a9db88f
BLAKE2b-256 checksum
How to use checksums
1c7020d7126276f9f37f69c52d7315ba8f872274136472ba595c74489e5f00b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.10 Linux/5.10.60.1-microsoft-standard-WSL2

Security for enum-actions 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page