Skip to content

Ocelots - Nad Hernandez#8

Open
nadxelleHernandez wants to merge 31 commits intoada-ac2:mainfrom
nadxelleHernandez:main
Open

Ocelots - Nad Hernandez#8
nadxelleHernandez wants to merge 31 commits intoada-ac2:mainfrom
nadxelleHernandez:main

Conversation

@nadxelleHernandez
Copy link
Copy Markdown

No description provided.

passed all integration tests
Copy link
Copy Markdown

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Great work Nad! I've left a mix of suggestions and questions to consider for feedback. Please reply here on Github or reach out on Slack if there's anything I can clarify =]

Comment thread swap_meet/electronics.py
self.type = type

def __str__(self) -> str:
elec_str = super().__str__()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really nice use of inheritance across the child classes 👍

Comment thread swap_meet/item.py
return str_item

def condition_description(self):
return self.cond_descriptions[int(self.condition)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like the use of int() to account for decimal condition values.

Comment thread swap_meet/item.py
Comment on lines +12 to +18
if id is not None:
if type(id) is int:
self.id = id
else:
raise TypeError("The id for Item object must be an integer")
else:
self.id = uuid.uuid4().int
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we could simplify the if/else tree a little by combining the id validation checks:

if id is not None and type(id) is not int:
    raise TypeError("The id for Item object must be an integer")

self.id = id if id else uuid.uuid4().int

Comment thread swap_meet/vendor.py
Comment on lines +13 to +14
if item not in self.inventory:
self.inventory.append(item)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice check to ensure the Vendor doesn't contain duplicates

Comment thread swap_meet/vendor.py
Comment on lines +10 to +11
if not item:
return item
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This could lead to some confusion around what types this function can return. If a user accidentally input a falsy value like the integer 0, then we would be returning an integer data type here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for this. I'm used to do this all the time since I've have mostly worked with hard typed languages like Java or C#. I would follow your advice and return the right type or None next time.

Comment thread swap_meet/vendor.py
Comment on lines +100 to +101
my_interest_item = other_vendor.get_best_by_category(my_priority)
their_interest_item = self.get_best_by_category(their_priority)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Loving the descriptive variable names 😊

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

they are kind of a pain to type but this large names help me think better about what I'm doing xD

Comment thread swap_meet/vendor.py
print("No inventory to display.")
return

for i in range(len(display_items)):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of range to give us an index to work with! Another way we could do this is with the enumerate function:

for index, item in enumerate(display_items, start=1): 
    print(f"{index}. {item}")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you! I love to learn other ways!


clothes = nad.get_electronics_by_type("")

assert clothes == []
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Love the tests you've added! 😄

Comment on lines +73 to +75
assert len(vendor.inventory) == 3
assert vendor.inventory == ["a", "b", "c"]
assert result is None No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great assertions, very complete checks =]

Comment on lines +134 to +136
assert not result
assert len(fatimah.inventory) == 3
assert len(jolie.inventory) == 0 No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great assertions, I would also suggest checking the inventory contents, since checks like the length being correct do not guarantee that the individual elements are still what we expect.

@nadxelleHernandez
Copy link
Copy Markdown
Author

Thank you Kelsey! I really appreciate all the feedback! It is a lot of work going through someone else's code

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