Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/workflows/client_build.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Client Build and Publish

on:
workflow_dispatch:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reintroduce an automatic publish trigger

This workflow now listens only to workflow_dispatch, so publishing no longer runs when a release is created (the previous client_build.yml handled release events). If your release process expects PyPI artifacts to be published automatically on release, this silently breaks that path and requires a manual run every time.

Useful? React with 👍 / 👎.


jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/richenum
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install Poetry and Dependencies
run: |
make quickstart-build
- name: Build package
run: |
make build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@ed0c5390c58e727690666d924fdd9d4791c13d80

27 changes: 8 additions & 19 deletions .github/workflows/python-version-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-ansi
- name: Run Tests
- name: Install Poetry and Dependencies
run: |
make quickstart
- name: Run lint checks
run: |
make lint
- name: Run tests
run: |
poetry run flake8 tests src
poetry run pytest
make test
14 changes: 14 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Developed and maintained by [Hearsay Social, Inc.](http://hearsaysocial.com).

## Contributors

- [Adam DePue](http://github.com/adepue)
- [Aron Radics](http://github.com/radaron)
- [Akshay Shah](http://github.com/akshayjshah)
- [Cordelia Notbohm](http://github.com/cnotbohm)
- [Dale Hui](http://github.com/dhui)
- [Istvan Nemeth](http://github.com/archiezgg)
- [Lachlan Imel](http://github.com/limelator)
- [Robert MacCloy](http://github.com/rbm)
- [Sam Vilain](http://github.com/samv)
- [Wyatt Paul](http://github.com/wyguy444)
14 changes: 0 additions & 14 deletions AUTHORS.rst

This file was deleted.

52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Changelog

## 2.1.0 (2026-16-03)
- Add Python 3.14 support and migrate to Poetry

## 2.0.2 (2024-10-01)

- Remove unavailable link for blog post from `README.md`.

## 2.0.1 (2024-06-06)

- Fix `README.md`.

## 2.0.0 (2024-06-04)

- Remove six
- Remove Python 3.7 support
- Add Python 3.9 and 3.10 support
- Remove `tox.ini`

## 1.2.1 (2016-09-16)

- `EnumLookupError` now inherits from built-in `LookupError`.

## 1.2.0 (2016-04-15)

- Add simple `LookupError` members that are thrown when `RichEnum.lookup` is called for a nonexistent attr/val pair.
- Users can choose to catch either the specific `LookupError` or continue to catch `EnumLookupError`.

## 1.1.0 (2014-04-17)

- Support for Python 3 and PyPy

## 1.0.4 (2013-12-03)

- Better unicode handling in `__str__`, `__unicode__`, and `__repr__`.

## 1.0.3 (2013-12-03)

- Stop throwing warnings.

## 1.0.2 (2013-11-05)

- Suppress warnings from mismatched type comparisons when generated in `RichEnum.lookup`.

## 1.0.1 (2013-09-20)

- Raise warnings when comparing enum values to other types, but not when checking membership or comparing to `None`.

## 1.0.0 (2013-08-16)

- Initial public release.
66 changes: 0 additions & 66 deletions CHANGELOG.rst

This file was deleted.

1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
REPO = $(shell git rev-parse --show-toplevel)
POETRY = poetry

.PHONY: hooks install-build install-dev poetry quickstart quickstart-build clean lint test build

hooks:
${REPO}/githooks/update_githooks.sh

install-build:
${POETRY} install --only=main
install-build: poetry
${POETRY} install --only=main --sync

install-dev:
${POETRY} install
install-dev: poetry
${POETRY} install --with dev --sync

poetry:
curl -sSL https://install.python-poetry.org | POETRY_VERSION=2.1.3 python3 -
curl -sSL https://install.python-poetry.org | POETRY_VERSION=2.2.1 python3 -
poetry cache clear pypi --all
poetry config virtualenvs.in-project true

Expand All @@ -32,4 +34,4 @@ test: clean
${POETRY} run pytest

build:
${POETRY} build
${POETRY} build
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# richenum

![Build Status](https://github.com/hearsaycorp/richenum/actions/workflows/python-version-tests.yml/badge.svg)
[![Latest PyPI Version](https://img.shields.io/pypi/v/richenum.svg)](https://pypi.python.org/pypi/richenum/)
[![Python versions](https://img.shields.io/pypi/pyversions/richenum.svg)](https://pypi.org/project/richenum/)
[![PyPI Downloads](https://img.shields.io/pypi/dm/richenum.svg)](https://pypi.org/project/richenum/)

## About

An enum library for Python.

- `enum`: A simple enum implementation that maps a variable to a constant.
- `RichEnum`: An enum implementation that offers more functionality than a basic enum, including a canonical name and a display name.
- `OrderedRichEnum`: Like `RichEnum`, but each enum value also has an index and iteration is sorted by index.

## Links

- [GitHub](https://github.com/hearsaycorp/richenum)
- [PyPI](https://pypi.python.org/pypi/richenum/)

## Installation

```bash
pip install richenum
```

## Example Usage

### enum

```python
>>> from richenum import enum
>>> MY_ENUM = enum(FOO=1, BAR=2)
>>> MY_ENUM.FOO
1
>>> MY_ENUM.BAR
2
```

### RichEnum

```python
>>> from richenum import RichEnum, RichEnumValue
>>> class MyRichEnum(RichEnum):
... FOO = RichEnumValue(canonical_name="foo", display_name="Foo")
... BAR = RichEnumValue(canonical_name="bar", display_name="Bar")
...
>>> MyRichEnum.FOO
RichEnumValue - canonical_name: 'foo' display_name: 'Foo'
>>> MyRichEnum.from_canonical("foo")
RichEnumValue - canonical_name: 'foo' display_name: 'Foo'
```

### OrderedRichEnum

```python
>>> from richenum import OrderedRichEnum, OrderedRichEnumValue
>>> class MyOrderedRichEnum(OrderedRichEnum):
... FOO = OrderedRichEnumValue(index=1, canonical_name="foo", display_name="Foo")
... BAR = OrderedRichEnumValue(index=2, canonical_name="bar", display_name="Bar")
...
>>> MyOrderedRichEnum.FOO
OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'
>>> MyOrderedRichEnum.from_canonical("foo")
OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'
>>> MyOrderedRichEnum.from_index(1)
OrderedRichEnumValue - idx: 1 canonical_name: 'foo' display_name: 'Foo'
```

## Related Packages

- `django-richenum`: Makes `RichEnum` and `OrderedRichEnum` available as model and form fields in Django.
[GitHub](https://github.com/hearsaycorp/django-richenum), [PyPI](https://pypi.python.org/pypi/django-richenum/)
- `enum`: Starting with Python 3.4, there is a standard library for enumerations. This package has a similar API but is not directly compatible.

## Contributing

1. Fork the repo from [GitHub](https://github.com/hearsaycorp/richenum).
2. Make your changes.
3. Add unittests for your changes.
4. Run [pep8](https://pypi.python.org/pypi/pep8), [pyflakes](https://pypi.python.org/pypi/pyflakes), and [pylint](https://pypi.python.org/pypi/pylint) to make sure your changes follow the Python style guide and do not have any errors.
5. Add yourself to the AUTHORS file (in alphabetical order).
6. Send a pull request from your fork to the main repo.
Loading
Loading