Skip to content

Conversation

@CatherineBandarchuk
Copy link

No description provided.

Copy link

@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 Kate! 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 =]



def __str__( self ):
return f"An object of type {super().get_category()} with id {str(self.id)}. It is made from {str(self.fabric)} fabric."

Choose a reason for hiding this comment

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

The superclass __str__ function returns f"An object of type {self.get_category()} with id {str(self.id)}". We could use this reduce a little bit of repetition:

base_msg = super().__str__()
return f"{base_msg}. It is made from {str(self.fabric)} fabric."  

Comment on lines +3 to +6
class Decor( Item ):

def __init__( self, id = None, condition = None, width = None, length = None ):
super().__init__(id, condition)

Choose a reason for hiding this comment

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

I'm noticing that in some places there are spaces around keywords or arguments in parentheses. It isn't common to add spaces between parentheses and what goes inside them, to be consistent across the code, I recommend removing them in the future.

Comment on lines +8 to +11
if fabric == None:
self.fabric = "Unknown"
else:
self.fabric = fabric

Choose a reason for hiding this comment

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

Another option here could be a python conditional assignment:

# Assigns self.fabric to the parameter fabric if it is truthy, 
# otherwise assigns self.fabric the value "Unknown"
self.fabric = fabric if fabric else "Unknown"

super().__init__( id, condition )

if fabric == None:
self.fabric = "Unknown"

Choose a reason for hiding this comment

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

Strings are an immutable type; unlike lists and dictionaries, we could set the default in the function definition to "Unknown", which could let us remove the if-check.


def __str__(self):

return f'''An object of type {super().get_category()} with id {str(self.id)}. It takes up a {str(self.width)} by {str(self.lenght)} sized space.'''

Choose a reason for hiding this comment

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

We would want to break this up over a couple lines to meet the best practice of keeping lines under 79 characters. One option could be to close the quotes and use a \ at the end of the line:

return f"An object of type {super().get_category()} with id {str(self.id)}. " \
       f"It takes up a {str(self.width)} by {str(self.lenght)} sized space."

if not my_item or not their_item:
return False

else:

Choose a reason for hiding this comment

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

We could remove the else here and unindent return self.swap_items(other_vendor, my_item, their_item) without changing the result of the function.

Comment on lines +137 to +139
if self.swap_by_id( other_vendor, my_item_id, their_item_id ):
return True
return False

Choose a reason for hiding this comment

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

We could remove the if/else by directly returning the result of self.swap_by_id.

assert item_c in tai.inventory

assert len(jesse.inventory) == 1
assert item_e in jesse.inventory No newline at end of file

Choose a reason for hiding this comment

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

Love the tests you added!

# *********************************************************************
# ****** Complete Assert Portion of this test **********
# *********************************************************************
assert result == None

Choose a reason for hiding this comment

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

Nice assert, we definitely want to confirm our return value is None. We generally also want to confirm that there weren't side affects or changes to the input that we didn't intend. What could we check about the vendor's inventory to confirm that its content didn’t change?

Choose a reason for hiding this comment

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

assert len(vendor.inventory) == 3

Choose a reason for hiding this comment

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

Definitely! Since knowing the length doesn't guarantee the individual elements are still what we expect, we might also check the elements of the inventory list.

# *********************************************************************
assert result == False
assert len(jolie.inventory) == 0
assert len(fatimah.inventory) == fatimah_len_l

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 the length being correct doesn't guarantee that the individual elements are still what we expect.

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