Skip to main content

A small, dependency-free library that provides additional subclasses of enum.StrEnum

Project description

stringenum

PyPI - Version PyPI - Python Version License Checked with mypy Ruff

GitHub Workflow Status (with event) GitHub Actions Workflow Status codecov

Table Of Contents

About

A small, dependency-free library that provides additional subclasses of enum.StrEnum.

Installation

stringenum is available on PyPI, so you can simply use pip to install it.

pip install stringenum

Usage

  • stringenum.CaseInsensitiveStrEnum - A subclass of StrEnum that supports case-insensitive lookup.

    >>> class Pet(CaseInsensitiveStrEnum):
    ...     CAT = "meow"
    ...     DOG = "bark"
    
    >>> Pet("Meow")
    <Pet.CAT: 'meow'>
    
    >>> Pet("BARK")     
    <Pet.DOG: 'bark'>
    
    >>> Pet["Cat"]
    <Pet.CAT: 'meow'>
    
    >>> Pet["dog"] 
    <Pet.DOG: 'bark'>
    
  • stringenum.DoubleSidedStrEnum - A subclass of StrEnum that supports double-sided lookup, allowing both member values and member names to be used for lookups. It also ensures that each member has a unique value.

    >>> class Status(DoubleSidedStrEnum):
    ...     PENDING = "waiting"
    ...     REJECTED = "denied"
    
    >>> Status("PENDING")
    <Status.PENDING: 'waiting'>
    
    >>> Status("waiting")
    <Status.PENDING: 'waiting'>
    
    >>> Status["REJECTED"]
    <Status.REJECTED: 'denied'>
    
    >>> Status["denied"]
    <Status.REJECTED: 'denied'>
    
  • stringenum.DoubleSidedCaseInsensitiveStrEnum - A subclass of StrEnum that supports case-insenitive double-sided lookup, allowing both member values and member names to be used for lookups. It also ensures that each member has a unique value.

    >>> class Status(DoubleSidedCaseInsensitiveStrEnum):
    ...     PENDING = "waiting"
    ...     REJECTED = "denied"
    
    >>> Status("pending")
    <Status.PENDING: 'waiting'>
    
    >>> Status("Waiting")
    <Status.PENDING: 'waiting'>
    
    >>> Status["Rejected"]
    <Status.REJECTED: 'denied'>
    
    >>> Status["DenieD"]
    <Status.REJECTED: 'denied'>
    

License

Distributed under the MIT License. See LICENSE for more information.

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

stringenum-0.1.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

stringenum-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stringenum-0.1.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for stringenum-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0921b0b8602bd08dd1fbafff4b15d0c4ee56f3a33d98a89aaf461614fc225698
MD5 81693cab08dde3abf3d211803a824708
BLAKE2b-256 7269095b6990da116fc44cd647962424457e231ad8a1ba9fbcb028047702c2d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for stringenum-0.1.0.tar.gz:

Publisher: release.yml on Ravencentric/stringenum

Attestations:

File details

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

File metadata

  • Download URL: stringenum-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for stringenum-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dd8b6abe0b9a43f2ef3066aae63b492201f8a1b315db7970559539c17cea379
MD5 b84845296267402f4bb0f542c8c637fa
BLAKE2b-256 317797d27ffc36ff69082825fd728883dc5a92efc5cd221792c2516a52fe3481

See more details on using hashes here.

Provenance

The following attestation bundles were made for stringenum-0.1.0-py3-none-any.whl:

Publisher: release.yml on Ravencentric/stringenum

Attestations:

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