Skip to content
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

Add check for missing year in models Release and Master #144

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

Conversation

akda5id
Copy link

@akda5id akda5id commented Apr 3, 2024

If so, make it None.

See for discussion #143

and Master, if so, make it None
@@ -529,6 +529,8 @@ class Release(PrimaryAPIObject):
def __init__(self, client, dict_):
super(Release, self).__init__(client, dict_)
self.data['resource_url'] = '{0}/releases/{1}'.format(client._base_url, dict_['id'])
if not 'year' in dict_:
dict_['year'] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, sorry for the delay in responding, I'm travelling and try to stay offline as much as I can ;-) Also excuse any sloppy formatting, I try to do my best while editing on mobile...

Anyway, interesting, and yes it's a quickfix but I'm wondering how we could make it a fix for potentially all fields that could be missing.

I'm probably just thinking out loud and havent thought all this through thoroughly enough, but:

We are defining year as a SimpleField here:

year = SimpleField() #:

Why wouldnt it be possible to fall back to None here already?

class SimpleField(Field):

descriptor class:

def __get__(self, instance, owner):

the ObjectDescriptor class does have some kind of fallback to None, we could try to do something similar in the SimpleDescriptor:

if self.optional and not response_dict:

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesnt year default to 0 if no year is specified so there should always be a value

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

Successfully merging this pull request may close these issues.

3 participants