code-for-montana / nonprofit-data

A tool to help make data about nonprofit organization more accessible.
MIT License
5 stars 2 forks source link

Move magic strings to "constants" #39

Open glesica opened 4 years ago

glesica commented 4 years ago

Create a constants.py file and move things like this (in index.py) into it to avoid sprinkling strings around:

                return_id=row["RETURN_ID"],
                filing_type=row["FILING_TYPE"],
                ein=row["EIN"],
                tax_period=row["TAX_PERIOD"],
                sub_date=row["SUB_DATE"],
                taxpayer_name=row["TAXPAYER_NAME"],
                return_type=row["RETURN_TYPE"],
                dln=row["DLN"],
                object_id=row["OBJECT_ID"],

We could also then define the IndexRecord dynamically and use those constants by using the syntax below:

        Employee = collections.namedtuple('Employee', ['name', 'id'])
glesica commented 4 years ago

The disadvantage to the syntax at the bottom is that we don't get type hinting, at least I'm pretty sure.