Skip to content

Commit 863e8c3

Browse files
committed
convert all enums to str - AutoEnums
1 parent 62ac8e1 commit 863e8c3

File tree

4 files changed

+62
-55
lines changed

4 files changed

+62
-55
lines changed

casparser/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def get_version():
77
try:
88
return version("casparser")
99
except PackageNotFoundError:
10-
return FALLBACK_VERSION
10+
return FALLBACK_VERSION # local development version
1111

1212

1313
__version__ = get_version()

casparser/enums.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
from enum import Enum, IntEnum, auto
1+
from enum import Enum, auto
22

33

4-
class FileType(IntEnum):
4+
class AutoEnum(Enum):
5+
# noinspection PyMethodParameters,PyTypeChecker
6+
def _generate_next_value_(name, start, count, last_values) -> str: # type: ignore
7+
"""
8+
Uses the name as the automatic value, rather than an integer
9+
See https://docs.python.org/3/library/enum.html#using-automatic-values for reference
10+
"""
11+
return name
12+
13+
14+
class FileType(AutoEnum):
515
"""Enum for CAS file source."""
616

7-
UNKNOWN = 0
8-
CAMS = 1
9-
KFINTECH = 2
17+
UNKNOWN = auto()
18+
CAMS = auto()
19+
KFINTECH = auto()
1020

1121

12-
class CASFileType(IntEnum):
22+
class CASFileType(AutoEnum):
1323
"""Enum for CAS file type"""
1424

15-
UNKNOWN = 0
16-
SUMMARY = 1
17-
DETAILED = 2
25+
UNKNOWN = auto()
26+
SUMMARY = auto()
27+
DETAILED = auto()
1828

1929

20-
class TransactionType(str, Enum):
21-
# noinspection PyMethodParameters
22-
def _generate_next_value_(name, start, count, last_values) -> str: # type: ignore
23-
"""
24-
Uses the name as the automatic value, rather than an integer
25-
See https://docs.python.org/3/library/enum.html#using-automatic-values for reference
26-
"""
27-
return name
30+
class TransactionType(str, AutoEnum):
2831

2932
PURCHASE = auto()
3033
PURCHASE_SIP = auto()

poetry.lock

Lines changed: 39 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "casparser"
3-
version = "0.4.7"
3+
version = "0.4.8"
44
description = "(Karvy/Kfintech/CAMS) Consolidated Account Statement (CAS) PDF parser"
55
authors = ["Sandeep Somasekharan <[email protected]>"]
66
homepage = "https://github.com/codereverser/casparser"
@@ -18,7 +18,7 @@ include = [ "CHANGELOG.md" ]
1818
[tool.poetry.dependencies]
1919
python = "^3.8"
2020
casparser-isin = ">=2021.6.1"
21-
click = "^7.1.2"
21+
click = "^8.0.1"
2222
colorama = "^0.4.4"
2323
"pdfminer.six" = "20201018"
2424
python-dateutil = "^2.8.1"

0 commit comments

Comments
 (0)