-
Notifications
You must be signed in to change notification settings - Fork 63
Edit3 #20
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
base: main
Are you sure you want to change the base?
Edit3 #20
Conversation
Melevir
left a comment
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 __name__ == "__main__": | ||
| assert compose_full_name(first_name="John", last_name="Doe", middle_name=None) == "Doe John" | ||
| assert compose_full_name(first_name="Ilya", last_name="Lebedev", middle_name="Alexeyevich") == "Lebedev Ilya Alexeyevich" | ||
| assert compose_full_name(first_name = "John", last_name = "Doe", middle_name = None) == "Doe John" |
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.
Не, когда у функции указываешь именованые аргументы, пробелы вокруг равно не нужны. Они нужны когда равно – это присваивание значения переменной.
|
|
||
| def is_point_in_square(point: ___, left_upper_corner: ___, right_bottom_corner: ___) -> ___: | ||
|
|
||
| def is_point_in_square(point: tuple[int, int], left_upper_corner: tuple[int, int], right_bottom_corner: tuple[int]) -> bool: |
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.
right_bottom_corner тоже из двух элементов состоит :)
|
|
||
|
|
||
| def get_transaction_amount(transaction_id: ___, transactions_amounts_map: ___) -> ___: | ||
| def get_transaction_amount(transaction_id:int, transactions_amounts_map: dict[int, decimal.decimal]) -> dict[int, decimal.decimal] | None: |
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.
decimal.Decimal. Заглавную букву потеряла
|
|
||
|
|
||
| def is_name_male(name: ___, name_gender_map: ___) -> ___: | ||
| def is_name_male(name: str, name_gender_map: dict[str, bool]) -> bool: |
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.
Возвращаемый тип не совсем точный
|
|
||
|
|
||
| def parse_receipt(raw_receipt: ___) -> ___: | ||
| def parse_receipt(raw_receipt: str) -> tuple[int, datetime.date, list[tuple[str, int, float]]]: |
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.
В тупле в последнем элементе не флоат
| class User(TypedDict): | ||
| "name": str | ||
| "age": int | ||
| "transactions_sums": list[int] |
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.
Тут кавычки лишние, правильно как в датаклассах.
| #def calculate_total_spent_for_user(user: TypedDict('User', 'name' = str, 'age' = int, 'transactions_sums' = list[int])) -> int: | ||
| #def calculate_total_spent_for_user(user: TypedDict('User', {'name': str, 'age': int, 'transactions_sums': list[int]})) -> int: | ||
|
|
||
| # пока на основе документации понимаю, что оба варианта верны, и именно в таком виде, без квадратных скобок |
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.
Синтаксически это может и верно, но в реальной жизни если и приходится использвоать тайпеддикт (редко), то пригождается тот способ, которым ты воспользовалась: ты отдельно определяешь тайпдикт как класс, а потом указываешь его в аннотации.
| def create_user(user_name: ___, user_age: ___, after_created: ___) -> ___: | ||
| pass | ||
|
|
||
| def create_user(user_name: str, user_age: int, after_created: function) -> None: |
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.
Тут пока неправильно. Посмотри, какие типы есть в модуле typing, может найдёшь чего :)
No description provided.