-
Notifications
You must be signed in to change notification settings - Fork 19
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
Updated to match errors lesson #1
base: solution
Are you sure you want to change the base?
Conversation
…tricks to return an empty list
app/routes/dog_routes.py
Outdated
@@ -8,12 +8,12 @@ def __init__(self, id, name, breed, tricks=None): | |||
self.name = name | |||
self.breed = breed | |||
if not tricks: | |||
tricks = [] | |||
self.tricks = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tricks
is None
, we'll assign self.tricks
to an empty list here, but then immediately overwrite it with None
when the line below self.tricks = tricks
runs. Maybe we replace all the code for self.tricks assignment with null-coalescing?
self.tricks = tricks or []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main branch of flasky doesn't look like a total solution. Is there a more appropriate place for this to go?
app/routes/dog_routes.py
Outdated
self.tricks = tricks | ||
|
||
def to_json(self): | ||
if not self.tricks: | ||
tricks = "No Tricks" | ||
tricks = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
abort
andmake_response
for 401, and 404self.tricks
to return empty list instead of a string to avoid mixing of data types.