Skip to content
Open
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
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Upload Python Package

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '*' # Push events to matching v*, i.e. v1.0, v20.15.10

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine gitchangelog pystache
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
13 changes: 7 additions & 6 deletions fast_enum/fastenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ class FastEnum(type):
# pylint: disable=bad-mcs-classmethod-argument,protected-access,too-many-locals
# pylint: disable=too-many-branches
def __new__(mcs, name, bases, namespace: Dict[Text, Any]):
attributes: List[Text] = [k for k in namespace.keys()
if (not k.startswith('_') and k.isupper())]
attributes += [k for k, v in namespace.get('__annotations__', {}).items()
if (not k.startswith('_') and k.isupper() and v == name)]
slots=set(namespace.get("__slots__",{}))
attributes: List[Text] = [k for k,v in namespace.items()
if (not k.startswith('_') and k not in slots and not callable(v))]
light_val = 0 + int(not bool(namespace.get('_ZERO_VALUED')))
for attr in attributes:
if attr in namespace:
Expand Down Expand Up @@ -88,7 +87,7 @@ def __new__(mcs, name, bases, namespace: Dict[Text, Any]):
namespace['__dir__'] = partial(FastEnum.__dir, bases=bases, namespace=namespace)
typ = type.__new__(mcs, name, bases, namespace)
if attributes:
typ._value_to_instance_map = {}
typ.__members__=typ._value_to_instance_map = {}
for instance_name in attributes:
val = namespace[instance_name]
if not isinstance(val, tuple):
Expand Down Expand Up @@ -186,7 +185,9 @@ def __delattr__(cls, item):
super().__delattr__(item)

def __getitem__(cls, item):
return getattr(cls, item)
if hasattr(cls,'__missing__') and hasattr(cls,item):
return getattr(cls, item)
return cls.__missing__(item)

def has_value(cls, value):
return value in cls._value_to_instance_map
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
long_description = rfd.read()

setuptools.setup(
name='fast-enum',
version='1.3.0',
name='fastenumplus',
version='1.4.0',
license='MIT',
platforms=['any'],
author='Andrey Semenov',
author_email='gatekeeper.mail@gmail.com',
description='A fast pure-python implementation of Enum',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/QratorLabs/fastenum',
url='https://github.com/hiddify/fastenum',
packages=['fast_enum'],
classifiers=[
'License :: OSI Approved :: MIT License',
Expand Down