Skip to content

Conversation

@glensc
Copy link
Owner

@glensc glensc commented Dec 11, 2022

Fix #14

Person and TVSeason _build methods are different, they call ids first before _ids, so therefore we need setter for ids. Unfortunately, that data is not even tested, so this did not come out in any way.

Typically it's like this:

  • def _build(self, data):
    """Build this :class:`Movie` object with the data in *data*"""
    for key, val in data.items():
    if hasattr(self, '_' + key):
    setattr(self, '_' + key, val)
    else:
    setattr(self, key, val)

but Person and TVSeason have:

  • def _build(self, data):
    for key, val in data.items():
    try:
    setattr(self, key, val)
    except AttributeError as ae:
    if not hasattr(self, '_' + key):
    raise ae
  • def _build(self, data):
    for key, val in data.items():
    try:
    setattr(self, key, val)
    except AttributeError as ae:
    if not hasattr(self, '_' + key):
    raise ae

@glensc
Copy link
Owner Author

glensc commented Dec 11, 2022

Should refactor this and add common class for the _build() method

@glensc glensc merged commit 664f96a into main Dec 11, 2022
@glensc glensc deleted the 14-fix branch December 11, 2022 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants