The enum class DescriptiveIntEnum was created in case this library supports parsing of XML files in the future. It allows a definition with 2-tuple members for code and description, and is subclassed by many classes in the package datatypes. For example:
class InvestorRelationsOfficerType(datatypes.DescriptiveIntEnum):
INVESTOR_RELATIONS_OFFICER = (1, 'Diretor de relações com investidores')
LIQUIDATOR = (2, 'Liquidante')
...
"Code" was intended to be used with parsing of XML files, whereas "description" is used when parsing CSV files. However, code is not being used currently, as there is no support for XML files.
So, YAGNI it by removing DescriptiveIntEnum from classes which are using it only for future XML support, since it is not needed and only adds up complexity/confusion. Instead, subclass those classes from IntEnum and leave the mapping to specialized modules/functions:
# In "datatypes/investor_relations.py"
class InvestorRelationsOfficerType(enum.IntEnum):
INVESTOR_RELATIONS_OFFICER = 0
LIQUIDATOR = 1
...
# In "csvio/fca.py"
def read_ir_officer_type(description: str):
if description == 'Diretor de relações com investidores':
return InvestorRelationsOfficerType.INVESTOR_RELATIONS_OFFICER
elif description == 'Liquidante':
return InvestorRelationsOfficerType.LIQUIDATOR
...
# In "xmlio/fca.py" (possible future module)
def read_ir_officer_type(code: int):
if code == 1: return InvestorRelationsOfficerType.INVESTOR_RELATIONS_OFFICER
elif code == 2: return InvestorRelationsOfficerType.LIQUIDATOR
...
Description
The enum class
DescriptiveIntEnum
was created in case this library supports parsing of XML files in the future. It allows a definition with 2-tuple members for code and description, and is subclassed by many classes in the packagedatatypes
. For example:"Code" was intended to be used with parsing of XML files, whereas "description" is used when parsing CSV files. However, code is not being used currently, as there is no support for XML files.
So, YAGNI it by removing
DescriptiveIntEnum
from classes which are using it only for future XML support, since it is not needed and only adds up complexity/confusion. Instead, subclass those classes fromIntEnum
and leave the mapping to specialized modules/functions: