Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MarieS-WiMLDS
Copy link
Contributor

@MarieS-WiMLDS MarieS-WiMLDS commented Oct 18, 2024

Add docstrings to the functions in the project class.

@MarieS-WiMLDS MarieS-WiMLDS linked an issue Oct 18, 2024 that may be closed by this pull request
@MarieS-WiMLDS MarieS-WiMLDS marked this pull request as draft October 18, 2024 14:29
@MarieS-WiMLDS MarieS-WiMLDS changed the title (doc) add docstrings to functions in project docs(project): add docstrings to functions in project Oct 18, 2024
@MarieS-WiMLDS MarieS-WiMLDS changed the title docs(project): add docstrings to functions in project docs(project): Add docstrings to functions in project Oct 18, 2024
@MarieS-WiMLDS MarieS-WiMLDS marked this pull request as ready for review October 18, 2024 14:49
Copy link
Member

@tuscland tuscland left a 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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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."""
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.

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.

doc: improve the docstring on the project class
2 participants