London | 25-SDC-July | Andrei Filippov | Sprint 4 | Prep Exercises#25
London | 25-SDC-July | Andrei Filippov | Sprint 4 | Prep Exercises#25Droid-An wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
bank_accounts.py
Outdated
| @@ -0,0 +1,36 @@ | |||
| from typing import Dict | |||
There was a problem hiding this comment.
No need to import Dict, you can just use build-in type starting from python 3.8 (dict vs Dict)
There was a problem hiding this comment.
Good to know, thank you. In the prep materials, we were asked to read the first sections of The Comprehensive Guide to mypy.
The note at the end of the Collection types section mentions the option to use only built-in types, but it also says:
However, there are some edge cases where it might not work, so in the meantime I'll suggest using the typing.List variants. This is detailed in PEP 585.
That's why I imported the types instead of using built-in ones.
type_guided_refactorings.py
Outdated
| class Person: | ||
| name: str | ||
| age: int | ||
| preferred_operating_systems: List[str] |
There was a problem hiding this comment.
Same, you can just use list if you use python3.8 or newer (no need to import it)
enums.py
Outdated
| return possible_laptops | ||
|
|
||
|
|
||
| def input_validation() -> Tuple[str, int, OperatingSystem]: |
There was a problem hiding this comment.
Tuple -> tuple (no import required)
enums.py
Outdated
| os_counts = count_operating_systems(laptops) | ||
| most_common_os, most_common_count = os_counts.most_common(1)[0] | ||
|
|
||
| user_count = os_counts[user.preferred_operating_system] |
There was a problem hiding this comment.
It is not a user count, but the count of laptops with preferred os, right? Can we make the name a bit clearer, like preferred_os to match most_common_os?
There was a problem hiding this comment.
Yeah, the new name sounds better
Learners, PR Template
Self checklist
Changelist
done prep exercises
Questions
no questions