C22 - Sphinx - Priyanka and Tatiana#1
Conversation
Add changes to wave 03
…ed_default_to_str to match string in Clothing class
|
Alternative function implementations created after discovering higher-order functions: |
|
We practiced writing docstrings for classes and methods. @yangashley, could you please give us feedback on this subject too? |
|
@Nerpassevera When writing docstrings you should adhere to some style for consistency. What style is used depends on team preferences so I can't speak to which specific style you should use. Docstrings should ideally contain all information that is relevant for using that class or method. Normally, that is less about describing the details of how the code works, and more about describing the purpose and general behavior. A couple example of guides: |
yangashley
left a comment
There was a problem hiding this comment.
Nice job on swap-meet, Priyanka and Tatiana!
I can see from the commit history that you made frequent commits, which is great!
Let me know if you have any questions about my comments.
| - `my_priority`, which represents a category that the `Vendor` wants to receive | ||
| - `their_priority`, which represents a category that `other_vendor` wants to receive | ||
| - The best item in my inventory that matches `their_priority` category is swapped with the best item in `other_vendor`'s inventory that matches `my_priority` | ||
| - If `other_vendor` has no item that matches `my_priority` category, swapping does not happen, and it returns `False` |
There was a problem hiding this comment.
Was this change accidentally committed?
If this change wasn't needed then take care to remove it from the list of files being added and committed. You can unstage a file for commit if you haven't run git commit yet and you can look at how to locally revert a commit if you already added/committed the file.
In industry, when you write code and open a PR it means you're asking to merge code into the main branch. Therefore, you will not be permitted to merge in changes that are not part of your feature work because it will cause noise in the commit history or bring in unnecessary changes to the codebase.
It's best practice to run git status to see what changes will be committed before you commit so you can catch stray changes like this.
| """ | ||
| A subclass of Item that represents an item of clothing. | ||
|
|
||
| Parameters: | ||
| ---------- | ||
| id : int, optional | ||
| Id of the item. Generated randomly by default | ||
| fabric : str, optional | ||
| Type of fabric the item is made of. Defaults to "Unknown" | ||
| condition : int, optional | ||
| An integer value representing the condition of the item, | ||
| where 1 is the worst and 5 is the best. Must be between 1 and 5. | ||
| Defaults to 0, indicating that no condition is unknown. | ||
| age : tuple, optional | ||
| A tuple of 3 integer representing date in format (yyyy, mm, dd). | ||
| Defaults to current day. | ||
|
|
||
| """ |
There was a problem hiding this comment.
If you were using Google's docstring guide for Python, then you can follow the info found in the guide here about writing docstrings for a class
| @@ -1,2 +1,31 @@ | |||
| class Clothing: | |||
| pass No newline at end of file | |||
| from .item import Item | |||
There was a problem hiding this comment.
Nice work importing Item since we're using by name as the parent class of Clothing 👍
| super().__init__(id, condition, age) | ||
| self.fabric = fabric |
There was a problem hiding this comment.
Nice work on here!
On line 23 you correctly set the default value for fabric to "Unknown".
On line 24 you properly call the initializer of the parent, and pass along the values the child wants to use.
Lastly, good work remembering to refactor the function definition to include age so that it can get set from the subclass
| item_type_line, produce_date_line = super().generate_description() | ||
| item_fabric_line = f"It is made from {self.fabric} fabric." | ||
| return "\n".join([item_type_line, item_fabric_line, produce_date_line]) |
There was a problem hiding this comment.
You could also do a one line return like:
f"{super().__str__()} It is made from {self.fabric} fabric."| assert result | ||
| assert len(tai.inventory) == 3 | ||
| assert len(jesse.inventory) == 3 | ||
| assert jesse.inventory == [item_d, item_e, item_c] |
There was a problem hiding this comment.
This assertions will fail if the order of items in each list somehow change. The README didn't specify that the order of inventory items needed to be maintained, so we probably don't need to constrain our tests and therefore our functions to these requirements. In fact, if you were to implement the swap that I suggested in a comment using multiple assignment, then these tests could fail because the order of elements would be changed.
While more verbose, you can check that elements are in a list like:
assert item_d in jesse.inventory
assert item_e in jesse.inventory
assert item_c in jesse.inventoryAnd since we're checking Jesse's inventory, it would be make the test more thorough to also check the items in Tai's inventory too.
| # ********************************************************************* | ||
| # ****** Complete Assert Portion of this test ********** | ||
| # ********************************************************************* | ||
| assert not result |
There was a problem hiding this comment.
swap_best_by_category should return False if a swap doesn't happen. More than be falsy, result is intended to return an actual boolean. So while we typically write something like
assert not resultin regular python, here we might prefer the more explicit check of
assert result == FalseSame comment applies to similar assertion written in another test below.
| assert tai.inventory == [item_a, item_b, item_c] | ||
| assert jesse.inventory == [item_d, item_e, item_f] |
There was a problem hiding this comment.
Do we need to consider order when checking the inventories of these vendors? If not, we don't need to test for it here.
Same comment applies to similar assertions written in another test below.
| print(f"{tai.inventory=}") | ||
| print(f"{jesse.inventory=}") | ||
| exchanged = tai.swap_by_newest(jesse) | ||
| print(f"{tai.inventory=}") | ||
| print(f"{jesse.inventory=}") |
There was a problem hiding this comment.
Remove debugging print statements when you're finished with them so they're not part of the PR.
| assert tai.inventory == [ item_b, item_a, item_f] | ||
| assert jesse.inventory == [ item_e, item_d, item_c ] |
There was a problem hiding this comment.
Nit: inconsistent whitespaces around square brackets.
| assert tai.inventory == [ item_b, item_a, item_f] | |
| assert jesse.inventory == [ item_e, item_d, item_c ] | |
| assert tai.inventory == [item_b, item_a, item_f] | |
| assert jesse.inventory == [item_e, item_d, item_c] |
PriyankaKaramchandani
left a comment
There was a problem hiding this comment.
@yangashley @Nerpassevera: Ashley I wanted to ask: when ever I want to pull changes of my team it asks me to always make my commits first. Only if I have made commits it allows me to proceed with git pull.
I read about stashing my changes with: git stash or git stash pull. Should I be using that?
No description provided.