Skip to content

Commit ea1901d

Browse files
authored
Merge pull request #22 from ericbn/update-README.md
Update README.md
2 parents 3111697 + e248d0a commit ea1901d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class HttpMethod(StrEnum):
3434

3535
assert HttpMethod.GET == "GET"
3636

37-
## You can use StrEnum values just like strings:
37+
# You can use StrEnum values just like strings:
3838

3939
import urllib.request
4040

4141
req = urllib.request.Request('https://www.python.org/', method=HttpMethod.HEAD)
4242
with urllib.request.urlopen(req) as response:
43-
html = response.read()
43+
html = response.read()
4444

45-
assert len(html) == 0 # HEAD requests do not (usually) include a body
45+
assert len(html) == 0 # HEAD requests do not (usually) include a body
4646
```
4747

4848
There are classes whose `auto()` value folds each member name to upper or lower
@@ -52,20 +52,24 @@ case:
5252
from enum import auto
5353
from strenum import LowercaseStrEnum, UppercaseStrEnum
5454

55+
5556
class Tag(LowercaseStrEnum):
5657
Head = auto()
5758
Body = auto()
5859
Div = auto()
5960

61+
6062
assert Tag.Head == "head"
6163
assert Tag.Body == "body"
6264
assert Tag.Div == "div"
6365

66+
6467
class HttpMethod(UppercaseStrEnum):
6568
Get = auto()
6669
Head = auto()
6770
Post = auto()
6871

72+
6973
assert HttpMethod.Get == "GET"
7074
assert HttpMethod.Head == "HEAD"
7175
assert HttpMethod.Post == "POST"
@@ -80,6 +84,7 @@ from strenum import CamelCaseStrEnum, PascalCaseStrEnum
8084
from strenum import KebabCaseStrEnum, SnakeCaseStrEnum
8185
from strenum import MacroCaseStrEnum
8286

87+
8388
class CamelTestEnum(CamelCaseStrEnum):
8489
OneTwoThree = auto()
8590

@@ -95,24 +100,28 @@ class KebabTestEnum(KebabCaseStrEnum):
95100
class SnakeTestEnum(SnakeCaseStrEnum):
96101
OneTwoThree = auto()
97102

98-
class SnakeTestEnum(MacroCaseStrEnum):
103+
104+
class MacroTestEnum(MacroCaseStrEnum):
99105
OneTwoThree = auto()
100106

107+
101108
assert CamelTestEnum.OneTwoThree == "oneTwoThree"
102109
assert PascalTestEnum.OneTwoThree == "OneTwoThree"
103110
assert KebabTestEnum.OneTwoThree == "one-two-three"
104111
assert SnakeTestEnum.OneTwoThree == "one_two_three"
105-
assert MacroCaseStrEnum.OneTwoThree == "ONE_TWO_THREE"
112+
assert MacroTestEnum.OneTwoThree == "ONE_TWO_THREE"
106113
```
107114

108115
As with any Enum you can, of course, manually assign values.
109116

110117
```python
111118
from strenum import StrEnum
112119

120+
113121
class Shape(StrEnum):
114122
CIRCLE = "Circle"
115123

124+
116125
assert Shape.CIRCLE == "Circle"
117126
```
118127

@@ -122,12 +131,12 @@ values--whatever you assign is the value they end up with.
122131
```python
123132
from strenum import KebabCaseStrEnum
124133

134+
125135
class Shape(KebabCaseStrEnum):
126136
CIRCLE = "Circle"
127137

128-
# This will raise an AssertionError because the value wasn't converted to
129-
# kebab-case.
130138

139+
# This will raise an AssertionError because the value wasn't converted to kebab-case.
131140
assert Shape.CIRCLE == "circle"
132141
```
133142

0 commit comments

Comments
 (0)