diff --git a/level_1/1.py b/level_1/1.py index 1813c9f..c79da05 100644 --- a/level_1/1.py +++ b/level_1/1.py @@ -1,7 +1,7 @@ from constants import ___ -def is_user_banned(user_id: ___) -> ___: +def is_user_banned(user_id: int) -> bool | None: pass diff --git a/level_1/10.py b/level_1/10.py index 77bbaf3..31f2845 100644 --- a/level_1/10.py +++ b/level_1/10.py @@ -1,7 +1,7 @@ from constants import ___ -def stringify(value: ___) -> ___: +def stringify(value: str | int | float | None) -> str | None: pass diff --git a/level_1/2.py b/level_1/2.py index 8a2c1bf..6970708 100644 --- a/level_1/2.py +++ b/level_1/2.py @@ -1,7 +1,7 @@ from constants import ___ -def is_adult(age: ___, country_name: ___) -> ___: +def is_adult(age: int, country_name: str) -> bool | None: pass diff --git a/level_1/3.py b/level_1/3.py index ae55bfd..911f607 100644 --- a/level_1/3.py +++ b/level_1/3.py @@ -1,10 +1,12 @@ from constants import ___ -def compose_full_name(first_name: ___, last_name: ___, middle_name: ___) -> ___: +def compose_full_name(first_name: str, last_name: str, middle_name: str | None) -> str | None: pass 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" + assert compose_full_name(first_name="Ilya", last_name="Lebedev", + middle_name="Alexeyevich") == "Lebedev Ilya Alexeyevich" diff --git a/level_1/4.py b/level_1/4.py index 4b4cbe5..84772d7 100644 --- a/level_1/4.py +++ b/level_1/4.py @@ -3,7 +3,7 @@ from constants import ___ -def calculate_age(date_of_birth: ___) -> ___: +def calculate_age(date_of_birth: datetime.date) -> int | None: pass diff --git a/level_1/5.py b/level_1/5.py index 0728530..236a5a9 100644 --- a/level_1/5.py +++ b/level_1/5.py @@ -1,7 +1,7 @@ from constants import ___ -def is_correct_email(raw_email: ___) -> ___: +def is_correct_email(raw_email: str) -> bool | None: pass diff --git a/level_1/6.py b/level_1/6.py index 7cb57fc..1ade048 100644 --- a/level_1/6.py +++ b/level_1/6.py @@ -1,10 +1,12 @@ from constants import ___ -def is_loan_amount_too_big(loan_amount_usd: ___, max_loan_amount_for_user_usd: ___) -> ___: +def is_loan_amount_too_big(loan_amount_usd: int | None, max_loan_amount_for_user_usd: int | None) -> bool | None: pass if __name__ == "__main__": - assert is_loan_amount_too_big(loan_amount_usd=1000, max_loan_amount_for_user_usd=4000) is False - assert is_loan_amount_too_big(loan_amount_usd=1000, max_loan_amount_for_user_usd=None) is False + assert is_loan_amount_too_big( + loan_amount_usd=1000, max_loan_amount_for_user_usd=4000) is False + assert is_loan_amount_too_big( + loan_amount_usd=1000, max_loan_amount_for_user_usd=None) is False diff --git a/level_1/7.py b/level_1/7.py index 68c6890..5ca7a80 100644 --- a/level_1/7.py +++ b/level_1/7.py @@ -1,9 +1,10 @@ from constants import ___ -def send_email(header: ___, text_content: ___, send_to: ___) -> ___: +def send_email(header: str, text_content: str, send_to: str) -> str | None: pass if __name__ == "__main__": - assert send_email(header="Test email", text_content="This is a test email", send_to="test@gmail.com") is None + assert send_email(header="Test email", text_content="This is a test email", + send_to="test@gmail.com") is None diff --git a/level_1/8.py b/level_1/8.py index 8ba8083..7ad874c 100644 --- a/level_1/8.py +++ b/level_1/8.py @@ -4,7 +4,7 @@ from constants import ___ -def get_user_balance(user_id: ___) -> ___: +def get_user_balance(user_id: uuid.UUID) -> decimal.Decimal | None: pass diff --git a/level_1/9.py b/level_1/9.py index 215588a..2adea3a 100644 --- a/level_1/9.py +++ b/level_1/9.py @@ -1,7 +1,7 @@ from constants import ___ -def is_correct_int(raw_int: ___) -> ___: +def is_correct_int(raw_int: str | None) -> bool | None: pass diff --git a/level_2/1.py b/level_2/1.py index c6ead64..e42e5f4 100644 --- a/level_2/1.py +++ b/level_2/1.py @@ -1,7 +1,7 @@ from constants import ___ -def get_avg_currency_rate(rates_history: ___) -> ___: +def get_avg_currency_rate(rates_history: list[float]) -> float | None: pass diff --git a/level_2/10.py b/level_2/10.py index 69f7bd0..284c4ce 100644 --- a/level_2/10.py +++ b/level_2/10.py @@ -1,7 +1,8 @@ from constants import ___ +from typing import Tuple -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, int]) -> bool | None: pass diff --git a/level_2/2.py b/level_2/2.py index e2ab2aa..3977b97 100644 --- a/level_2/2.py +++ b/level_2/2.py @@ -1,9 +1,10 @@ from constants import ___ -def is_recovery_code_correct(code: ___, user_codes: ___) -> ___: +def is_recovery_code_correct(code: str, user_codes: list[str]) -> bool | None: pass if __name__ == "__main__": - assert is_recovery_code_correct(code="5212", user_codes=["1862", "8172", "7212"]) is False + assert is_recovery_code_correct(code="5212", user_codes=[ + "1862", "8172", "7212"]) is False diff --git a/level_2/3.py b/level_2/3.py index 8487e4b..4b8efcd 100644 --- a/level_2/3.py +++ b/level_2/3.py @@ -3,7 +3,7 @@ from constants import ___ -def get_transaction_amount(transaction_id: ___, transactions_amounts_map: ___) -> ___: +def get_transaction_amount(transaction_id: int, transactions_amounts_map: dict[int, decimal.Decimal]) -> decimal.Decimal | None: pass @@ -13,5 +13,7 @@ def get_transaction_amount(transaction_id: ___, transactions_amounts_map: ___) - 514: decimal.Decimal("164.1"), 372: decimal.Decimal("92"), } - assert get_transaction_amount(transaction_id=156, transactions_amounts_map=transactions_amounts_map) == decimal.Decimal("30.6") - assert get_transaction_amount(transaction_id=1000, transactions_amounts_map=transactions_amounts_map) is None + assert get_transaction_amount( + transaction_id=156, transactions_amounts_map=transactions_amounts_map) == decimal.Decimal("30.6") + assert get_transaction_amount( + transaction_id=1000, transactions_amounts_map=transactions_amounts_map) is None diff --git a/level_2/4.py b/level_2/4.py index 791b2e0..2e927c8 100644 --- a/level_2/4.py +++ b/level_2/4.py @@ -1,7 +1,7 @@ from constants import ___ -def ban_users(users_ids: ___) -> ___: +def ban_users(users_ids: set[int]) -> int | None: pass diff --git a/level_2/5.py b/level_2/5.py index 2b0ce2d..e8e6401 100644 --- a/level_2/5.py +++ b/level_2/5.py @@ -1,7 +1,7 @@ from constants import ___ -def get_current_user() -> ___: +def get_current_user() -> tuple[str, int, str] | None: pass diff --git a/level_2/6.py b/level_2/6.py index af117e9..d76e15c 100644 --- a/level_2/6.py +++ b/level_2/6.py @@ -1,7 +1,7 @@ from constants import ___ -def is_name_male(name: ___, name_gender_map: ___) -> ___: +def is_name_male(name: str, name_gender_map: dict[str, bool]) -> bool | None: pass diff --git a/level_2/7.py b/level_2/7.py index f8f7f6f..0cd9c28 100644 --- a/level_2/7.py +++ b/level_2/7.py @@ -1,9 +1,10 @@ from constants import ___ -def calculate_total_spent_for_user(user: ___) -> ___: +def calculate_total_spent_for_user(user: tuple[str, int, list[int]]) -> int | None: pass if __name__ == "__main__": - assert calculate_total_spent_for_user(user=("Ilya", 32, [102, 15, 63, 12])) == 192 + assert calculate_total_spent_for_user( + user=("Ilya", 32, [102, 15, 63, 12])) == 192 diff --git a/level_2/8.py b/level_2/8.py index 1801197..d67e3b6 100644 --- a/level_2/8.py +++ b/level_2/8.py @@ -1,7 +1,7 @@ from constants import ___ -def calculate_total_spent_for_users(users_ids: ___, users_ids_to_users_map: ___) -> ___: +def calculate_total_spent_for_users(users_ids: set[int], users_ids_to_users_map: dict[int, tuple[str, int, list[int]]]) -> int | None: pass diff --git a/level_2/9.py b/level_2/9.py index 693804a..f867d68 100644 --- a/level_2/9.py +++ b/level_2/9.py @@ -1,9 +1,10 @@ import datetime from constants import ___ +from datetime import date -def parse_receipt(raw_receipt: ___) -> ___: +def parse_receipt(raw_receipt: str) -> tuple[int, date, list[tuple[str, int, float]]] | None: pass diff --git a/level_3/1.py b/level_3/1.py index 9578f5e..f9a234e 100644 --- a/level_3/1.py +++ b/level_3/1.py @@ -1,9 +1,10 @@ import decimal from constants import ___ +from typing import Mapping -def get_transaction_amount(transaction_id: ___, transactions_amounts_map: ___) -> ___: +def get_transaction_amount(transaction_id: int, transactions_amounts_map: Mapping[int, decimal.Decimal]) -> decimal.Decimal | None: # попробуйте использовать typing.Mapping: transactions_amounts_map по смыслу не должен меняться внутри функции pass @@ -14,5 +15,7 @@ def get_transaction_amount(transaction_id: ___, transactions_amounts_map: ___) - 514: decimal.Decimal("164.1"), 372: decimal.Decimal("92"), } - assert get_transaction_amount(transaction_id=156, transactions_amounts_map=transactions_amounts_map) == decimal.Decimal("30.6") - assert get_transaction_amount(transaction_id=1000, transactions_amounts_map=transactions_amounts_map) is None + assert get_transaction_amount( + transaction_id=156, transactions_amounts_map=transactions_amounts_map) == decimal.Decimal("30.6") + assert get_transaction_amount( + transaction_id=1000, transactions_amounts_map=transactions_amounts_map) is None diff --git a/level_3/2.py b/level_3/2.py index edde766..ce3223f 100644 --- a/level_3/2.py +++ b/level_3/2.py @@ -1,8 +1,14 @@ from constants import ___ +from typing import TypedDict -def calculate_total_spent_for_user(user: ___) -> ___: - # попробуй тут воспользовать typing.TypedDict +class User(TypedDict): + name: str + age: int + transactions_sums: list[int] + + +def calculate_total_spent_for_user(user: User) -> int | None: pass diff --git a/level_3/3.py b/level_3/3.py index 50ed15a..f6300fa 100644 --- a/level_3/3.py +++ b/level_3/3.py @@ -1,7 +1,8 @@ from constants import ___ +from typing import Callable -def create_user(user_name: ___, user_age: ___, after_created: ___) -> ___: +def create_user(user_name: str, user_age: int, after_created: Callable[[int], str | None]) -> str | None: pass