biocore / biocore/microsetta-private-api
Reduce magic values from query returns
- Dominant language
- Python
- Stars
- 6
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
There are a few instances in the codebase of reliance on hardcoded numeric values for indexing. It would be pleasant for these tuples to instead to use `namedtuple`s or `dict` in order to improve readability.
An example of hardcoded indexing can be found [here](https://github.com/biocore/microsetta-private-api/blob/52798b9823332114aa98b20a939cabdbbbdc1527/repo/account_repo.py#L16-L18).
It looks like `psycopg2` provides a solution here through [`cursor_factory`](http://initd.org/psycopg/docs/extras.html#namedtuple-cursor). An example for `dict` can be found above.
For a motivation, this would change the code from:
```python
foo = some_factory(row[0], row[1], row[2])
```
To:
```python
foo = some_factory(row.first_field, row.some_other_column, row.thing)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.