Skip to content

Commit 41a37e0

Browse files
committed
exercise 10 completed
1 parent 87f4a2e commit 41a37e0

4 files changed

Lines changed: 18 additions & 51 deletions

File tree

‎Sprint 5 Prep Exercises/account.py‎

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,21 @@ def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop]
3939

4040
for person in people:
4141
possible_laptops = find_possible_laptops(laptops, person)
42-
print(f"Possible laptops for {person.name}: {possible_laptops}")
42+
print(f"Possible laptops for {person.name}: {possible_laptops}")
43+
44+
# Try changing the type annotation of Person.preferred_operating_system from str to List[str].
45+
# Run mypy on the code.
46+
47+
# exercise_10.py:29: error: Argument "preferred_operating_system" to "Person" has incompatible type "str"; expected "list[str]" [arg-type]
48+
# exercise_10.py:30: error: Argument "preferred_operating_system" to "Person" has incompatible type "str"; expected "list[str]" [arg-type]
49+
50+
51+
# It tells us different places that our code is now wrong, because we’re passing values of the wrong type.
52+
# We probably also want to rename our field - lists are plural. Rename the field to preferred_operating_systems.
53+
# Run mypy again.
54+
55+
# exercise_10.py:23: error: "Person" has no attribute "preferred_operating_system"; maybe "preferred_operating_systems"? [attr-defined]
56+
# exercise_10.py:29: error: Unexpected keyword argument "preferred_operating_system" for "Person"; did you mean "preferred_operating_systems"? [call-arg]
57+
# exercise_10.py:30: error: Unexpected keyword argument "preferred_operating_system" for "Person"; did you mean "preferred_operating_systems"? [call-arg]
58+
59+
# Fix all of the places that mypy tells you need changing. Make sure the program works as you’d expect.

‎Sprint 5 Prep Exercises/person.py‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)