-
Notifications
You must be signed in to change notification settings - Fork 0
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
docs(project): Add docstrings to functions in project #541
base: main
Are you sure you want to change the base?
Conversation
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.
Minor adjustments for more idiomatic english, simplifications, and one fix (view instead of item).
@@ -41,6 +41,7 @@ def __init__( | |||
@singledispatchmethod | |||
def put(self, key: str, value: Any, on_error: Literal["warn", "raise"] = "warn"): | |||
"""Add a value to the Project. | |||
If an item with the same key already exists, it replaces the value with the new one. |
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 an item with the same key already exists, its value is replaced by the new one.
@@ -112,7 +113,17 @@ def put_item(self, key: str, item: Item): | |||
self.item_repository.put_item(key, item) | |||
|
|||
def get(self, key: str) -> Any: | |||
"""Get the value corresponding to `key` from the Project.""" | |||
"""Get and returns the value corresponding to `key` from the Project. |
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.
Returns the value corresponding to key
from the Project.
Raises | ||
------ | ||
KeyError | ||
Renders KeyError if the input key doesn't correspond to any item. |
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.
Raises a KeyError if the key does not correspond to any item.
@@ -131,31 +142,96 @@ def get(self, key: str) -> Any: | |||
raise ValueError(f"Item {item} is not a known item type.") | |||
|
|||
def get_item(self, key: str) -> Item: | |||
"""Add the Item corresponding to `key` from the Project.""" | |||
"""Get and returns the Item corresponding to `key` from the Project. |
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.
Returns the item corresponding to key
from the Project.
Raises | ||
------ | ||
KeyError | ||
Renders KeyError if the input key doesn't correspond to any item.""" |
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.
Raises a KeyError if the key does not correspond to any item.
Raises | ||
------ | ||
KeyError | ||
Renders KeyError if the input key doesn't correspond to any item. |
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.
Raises a KeyError if the key does not correspond to any item.
return self.item_repository.keys() | ||
|
||
def delete_item(self, key: str): | ||
"""Delete an item from the Project.""" | ||
"""Delete an item from the Project. |
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.
Deletes the item corresponding to key
from the Project.
self.item_repository.delete_item(key) | ||
|
||
def put_view(self, key: str, view: View): | ||
"""Add a view to the Project.""" | ||
self.view_repository.put_view(key, view) | ||
|
||
def get_view(self, key: str) -> View: | ||
"""Get the view corresponding to `key` from the Project.""" | ||
"""Get the view corresponding to `key` from the Project. |
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.
Returns the view corresponding to key
from the Project.
Raises | ||
------ | ||
KeyError | ||
Renders KeyError if the input key doesn't correspond to any item. |
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.
Raises a KeyError if the key does not correspond to any view.
Raises | ||
------ | ||
KeyError | ||
Renders KeyError if the input key doesn't correspond to any view. |
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.
Raises a KeyError if the key does not correspond to any view.
Add docstrings to the functions in the project class.