Added github integration

This commit is contained in:
2025-12-02 14:32:10 +00:00
parent b6dd8b8fe2
commit 4076c4bf83
762 changed files with 193089 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 James C Sinclair
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,211 @@
Metadata-Version: 2.1
Name: StrEnum
Version: 0.4.15
Summary: An Enum that inherits from str.
Home-page: https://github.com/irgeek/StrEnum
Author: James Sinclair
Author-email: james@nurfherder.com
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: docs
Requires-Dist: sphinx ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
Requires-Dist: myst-parser[linkify] ; extra == 'docs'
Provides-Extra: release
Requires-Dist: twine ; extra == 'release'
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: pytest-black ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'
Requires-Dist: pytest-pylint ; extra == 'test'
Requires-Dist: pylint ; extra == 'test'
# StrEnum
[![Build Status](https://github.com/irgeek/StrEnum/workflows/Python%20package/badge.svg)](https://github.com/irgeek/StrEnum/actions)
StrEnum is a Python `enum.Enum` that inherits from `str` to complement
`enum.IntEnum` in the standard library. Supports python 3.7+.
## Installation
You can use [pip](https://pip.pypa.io/en/stable/) to install.
```bash
pip install StrEnum
```
## Usage
```python
from enum import auto
from strenum import StrEnum
class HttpMethod(StrEnum):
GET = auto()
HEAD = auto()
POST = auto()
PUT = auto()
DELETE = auto()
CONNECT = auto()
OPTIONS = auto()
TRACE = auto()
PATCH = auto()
assert HttpMethod.GET == "GET"
# You can use StrEnum values just like strings:
import urllib.request
req = urllib.request.Request('https://www.python.org/', method=HttpMethod.HEAD)
with urllib.request.urlopen(req) as response:
html = response.read()
assert len(html) == 0 # HEAD requests do not (usually) include a body
```
There are classes whose `auto()` value folds each member name to upper or lower
case:
```python
from enum import auto
from strenum import LowercaseStrEnum, UppercaseStrEnum
class Tag(LowercaseStrEnum):
Head = auto()
Body = auto()
Div = auto()
assert Tag.Head == "head"
assert Tag.Body == "body"
assert Tag.Div == "div"
class HttpMethod(UppercaseStrEnum):
Get = auto()
Head = auto()
Post = auto()
assert HttpMethod.Get == "GET"
assert HttpMethod.Head == "HEAD"
assert HttpMethod.Post == "POST"
```
As well as classes whose `auto()` value converts each member name to camelCase,
PascalCase, kebab-case, snake_case and MACRO_CASE:
```python
from enum import auto
from strenum import CamelCaseStrEnum, PascalCaseStrEnum
from strenum import KebabCaseStrEnum, SnakeCaseStrEnum
from strenum import MacroCaseStrEnum
class CamelTestEnum(CamelCaseStrEnum):
OneTwoThree = auto()
class PascalTestEnum(PascalCaseStrEnum):
OneTwoThree = auto()
class KebabTestEnum(KebabCaseStrEnum):
OneTwoThree = auto()
class SnakeTestEnum(SnakeCaseStrEnum):
OneTwoThree = auto()
class MacroTestEnum(MacroCaseStrEnum):
OneTwoThree = auto()
assert CamelTestEnum.OneTwoThree == "oneTwoThree"
assert PascalTestEnum.OneTwoThree == "OneTwoThree"
assert KebabTestEnum.OneTwoThree == "one-two-three"
assert SnakeTestEnum.OneTwoThree == "one_two_three"
assert MacroTestEnum.OneTwoThree == "ONE_TWO_THREE"
```
As with any Enum you can, of course, manually assign values.
```python
from strenum import StrEnum
class Shape(StrEnum):
CIRCLE = "Circle"
assert Shape.CIRCLE == "Circle"
```
Doing this with the case-changing classes, though, won't manipulate
values--whatever you assign is the value they end up with.
```python
from strenum import KebabCaseStrEnum
class Shape(KebabCaseStrEnum):
CIRCLE = "Circle"
# This will raise an AssertionError because the value wasn't converted to kebab-case.
assert Shape.CIRCLE == "circle"
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.
Please ensure tests pass before submitting a PR. This repository uses
[Black](https://black.readthedocs.io/en/stable/) and
[Pylint](https://www.pylint.org/) for consistency. Both are run automatically
as part of the test suite.
## Running the tests
Tests can be run using `make`:
```
make test
```
This will create a virutal environment, install the module and its test
dependencies and run the tests. Alternatively you can do the same thing
manually:
```
python3 -m venv .venv
.venv/bin/pip install .[test]
.venv/bin/pytest
```
## License
[MIT](https://choosealicense.com/licenses/mit/)
**N.B. Starting with Python 3.11, `enum.StrEnum` is available in the standard
library. This implementation is _not_ a drop-in replacement for the standard
library implementation. Specifically, the Python devs have decided to case fold
name to lowercase by default when `auto()` is used which I think violates the
principle of least surprise.**

View File

@@ -0,0 +1,18 @@
StrEnum-0.4.15.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
StrEnum-0.4.15.dist-info/LICENSE,sha256=vNcz0KRlIhYrldurYffNwcPjaGHfoSfWikQ1JA02rTY,1073
StrEnum-0.4.15.dist-info/METADATA,sha256=xLhPNsn2ieV9BR8L-FvFTMMhG6x99Rj536PM2hf1KII,5290
StrEnum-0.4.15.dist-info/RECORD,,
StrEnum-0.4.15.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
StrEnum-0.4.15.dist-info/top_level.txt,sha256=lsVIlgvvAAG9MBoLNwpPgG5wMT33blIUUoJo215Y-N0,8
strenum/__init__.py,sha256=oOsokqYYQVwTBbjrnXdR89RMcx8q6aGmWl--dlf2VCE,8530
strenum/__init__.pyi,sha256=-qJs9THlVGY3_o_bVeE7jUevjWteU_zOy7cZkp3MGzA,1415
strenum/__pycache__/__init__.cpython-311.pyc,,
strenum/__pycache__/_name_mangler.cpython-311.pyc,,
strenum/__pycache__/_version.cpython-311.pyc,,
strenum/__pycache__/mixins.cpython-311.pyc,,
strenum/_name_mangler.py,sha256=o11M5-bURW2RBvRTYXFQIPNeqLzburdoWLIqk8X3ydw,3397
strenum/_name_mangler.pyi,sha256=91p30d_kMAFsX5r9pqvSeordIf4VONDymQhcEvot2XA,551
strenum/_version.py,sha256=ylMBlzCLrUBhNvBnKtzTqGzDqHnEmoQkm3K6p5Gx5ms,498
strenum/mixins.py,sha256=BtOEx1hrAZ1YhDURDjLTrunKVneVtezSfkBq3sZXqxE,2042
strenum/mixins.pyi,sha256=lV6wiQAxZMvMSUUtnxzV1QSsyBDzgpobywiGCwRwm30,387
strenum/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0

View File

@@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.40.0)
Root-Is-Purelib: true
Tag: py3-none-any