Skip to content

Commit ff0cade

Browse files
committed
Add docstrings updates
1 parent b902708 commit ff0cade

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

python-docstrings/docstring_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ def determine_magic_level(magic_number):
22
"""
33
Multiply a wizard's favorite number by 3 to reveal their magic level.
44
"""
5+
return magic_number * 3
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from books import get_harry_potter_books
1+
from multi_line_docstring import get_harry_potter_books
22

3-
print(get_harry_potter_books().__doc__)
3+
print(get_harry_potter_books.__doc__)

python-docstrings/google_style.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ def get_magic_items(user_id, include_potions=False):
44
55
Args:
66
user_id (int): The ID of the user whose items should be retrieved.
7-
include_potions (bool, optional): include a potions option.
7+
include_potions (bool, optional): Whether to include potions in the result.
88
99
Returns:
1010
list[str]: A list of item names associated with the user.
1111
"""
12-
return ["wand", "cloak", "crystal ball"]
12+
items = ["wand", "cloak", "crystal ball"]
13+
if include_potions:
14+
items.extend(["healing potion", "invisibility potion"])
15+
return items

python-docstrings/minimal_return_details_fix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ def generate_shield(strength):
88
Returns:
99
str: A human-readable description of the generated shield.
1010
"""
11+
return f"Shield with strength {strength}"

python-docstrings/navigation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
This module provides tools for creating and managing magical maps.
33
Example:
4-
from magic_maps import build_map
4+
from navigation import build_map
55
build_map(["mandrake", "phoenix feather", "tree bark"], heat_level=3)
66
"""

python-docstrings/restructuredText.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def cast_spell(wand, incantation, target=None):
22
"""
33
Cast a magical spell using a wand and incantation.
4-
This function stimulates casting a spell. With no
4+
This function simulates casting a spell. With no
55
target specified, it is cast into the void.
66
77
:param wand: The wand used to do the spell-casting deed.
@@ -18,7 +18,7 @@ def cast_spell(wand, incantation, target=None):
1818
if not wand:
1919
raise ValueError("You can't cast spells without a wand!")
2020
if incantation not in valid_incantations:
21-
raise ValueError("Incantation not recognozed.")
21+
raise ValueError("Incantation not recognized.")
2222
if target:
2323
return f"{incantation} hits {target} with magic speed!"
2424
return f"{incantation} is cast into the void...sparkles shimmer faintly"

python-docstrings/vague_descriptions_fix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ def brew(potion_ingredients):
88
Returns:
99
str: The name of the completed potion.
1010
"""
11+
return f"Magical potion brewed from {', '.join(potion_ingredients)}"

0 commit comments

Comments
 (0)