Skip to content

Use the correct data structures for exceptions #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

NyanHelsing
Copy link
Contributor

@NyanHelsing NyanHelsing commented Aug 6, 2018

Ticket

No ticket

Purpose

A tuple is the correct data structure for cases where the position in
the structure has meaning rather than being ordered, so a list of tuples
is the correct data structure for the stack here.

A couple links to relevant discussion:

Though tuples may seem similar to lists, they are often used in different situations and for different purposes. Tuples are immutable, and usually contain a heterogeneous sequence of elements that are accessed via unpacking (see later in this section) or indexing (or even by attribute in the case of namedtuples). Lists are mutable, and their elements are usually homogeneous and are accessed by iterating over the list.

https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences
http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists/
https://stackoverflow.com/questions/626759/whats-the-difference-between-lists-and-tuples

Changes

Replace lists where tuples are more correct

Side effects

Doubtful

QA Notes

N/A

Deployment Notes

N/A

A tuple is the correct data struuucture for cases where the position in
the structure has meaning rather than significance, so a list of tuples
is the correct data structure for the stack here.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 71.218% when pulling 18d2ad8 on birdbrained:ft/use-correct-types-for-errors into d15d322 on CenterForOpenScience:develop.

@NyanHelsing NyanHelsing changed the title Uses the correct data structures for exceptions Use the correct data structures for exceptions Aug 6, 2018
@NyanHelsing NyanHelsing requested a review from felliott August 6, 2018 19:22
Copy link
Contributor

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 🎆 Tuple makes more sense than list here. Just one more thing to double check. Do we have any usage of the self.attr_stack that may expecting a list for the error and message? If so, we need to update them as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants