diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9e484a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +env/ +mypy_cache/ +typing_challenges/ \ No newline at end of file diff --git a/constants.py b/constants.py index 21b2c30..41b6957 100644 --- a/constants.py +++ b/constants.py @@ -1 +1 @@ -___ = None +none_type = ___ diff --git a/level_1/1.py b/level_1/1.py index 1813c9f..97ba86b 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: pass diff --git a/level_1/10.py b/level_1/10.py index d31d5d1..8ba9d07 100644 --- a/level_1/10.py +++ b/level_1/10.py @@ -1,9 +1,11 @@ import uuid -from constants import ___ +from constants import none_type +from typing import Any -def stringify(value: ___) -> ___: +# сначала написала none_type|str, потому что хотела избежать Any +def stringify(value: Any) -> str: pass diff --git a/level_1/2.py b/level_1/2.py index 8a2c1bf..8558a13 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: pass diff --git a/level_1/3.py b/level_1/3.py index ae55bfd..6def7ca 100644 --- a/level_1/3.py +++ b/level_1/3.py @@ -1,10 +1,10 @@ -from constants import ___ +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_type) -> str: 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="John", last_name="Doe", middle_name=none_type) == "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..4522ac4 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: pass diff --git a/level_1/5.py b/level_1/5.py index 0728530..9b06931 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: pass diff --git a/level_1/6.py b/level_1/6.py index 7cb57fc..f25c981 100644 --- a/level_1/6.py +++ b/level_1/6.py @@ -1,7 +1,7 @@ -from constants import ___ +from constants import none_type -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, max_loan_amount_for_user_usd: int|none_type) -> bool: pass diff --git a/level_1/7.py b/level_1/7.py index 68c6890..56a3b31 100644 --- a/level_1/7.py +++ b/level_1/7.py @@ -1,7 +1,7 @@ -from constants import ___ +from constants import none_type -def send_email(header: ___, text_content: ___, send_to: ___) -> ___: +def send_email(header: str, text_content: str, send_to: str) -> none_type: pass diff --git a/level_1/8.py b/level_1/8.py index 8ba8083..24f3f2f 100644 --- a/level_1/8.py +++ b/level_1/8.py @@ -1,10 +1,10 @@ import decimal import uuid -from constants import ___ +from constants import none_type -def get_user_balance(user_id: ___) -> ___: +def get_user_balance(user_id: uuid.UUID) -> decimal.Decimal|none_type: pass diff --git a/level_1/9.py b/level_1/9.py index fb7fc80..9ab6d61 100644 --- a/level_1/9.py +++ b/level_1/9.py @@ -1,9 +1,9 @@ import uuid -from constants import ___ +from constants import none_type -def is_correct_int(raw_int: ___) -> ___: +def is_correct_int(raw_int: str|none_type) -> bool: pass diff --git a/level_2/1.py b/level_2/1.py index c6ead64..f6ebd55 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: pass diff --git a/level_2/10.py b/level_2/10.py index 69f7bd0..71d934f 100644 --- a/level_2/10.py +++ b/level_2/10.py @@ -1,7 +1,8 @@ from constants import ___ -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: pass diff --git a/level_2/2.py b/level_2/2.py index e2ab2aa..e9d4a9b 100644 --- a/level_2/2.py +++ b/level_2/2.py @@ -1,7 +1,7 @@ from constants import ___ -def is_recovery_code_correct(code: ___, user_codes: ___) -> ___: +def is_recovery_code_correct(code: str, user_codes: list[str]) -> bool: pass diff --git a/level_2/3.py b/level_2/3.py index 8487e4b..140bd98 100644 --- a/level_2/3.py +++ b/level_2/3.py @@ -1,9 +1,9 @@ import decimal -from constants import ___ +from constants import none_type -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_type: pass diff --git a/level_2/4.py b/level_2/4.py index 791b2e0..8136322 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: pass diff --git a/level_2/5.py b/level_2/5.py index 2b0ce2d..b6b86f4 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]: pass diff --git a/level_2/6.py b/level_2/6.py index af117e9..2f466cb 100644 --- a/level_2/6.py +++ b/level_2/6.py @@ -1,10 +1,11 @@ from constants import ___ -def is_name_male(name: ___, name_gender_map: ___) -> ___: +def is_name_male(name: str, name_gender_map: dict[str, bool]) -> bool: pass + if __name__ == "__main__": name_gender_map = { "John": True, diff --git a/level_2/7.py b/level_2/7.py index f8f7f6f..3ddf258 100644 --- a/level_2/7.py +++ b/level_2/7.py @@ -1,7 +1,7 @@ from constants import ___ -def calculate_total_spent_for_user(user: ___) -> ___: +def calculate_total_spent_for_user(user: tuple(str,int,list[int])) -> int: pass diff --git a/level_2/8.py b/level_2/8.py index 1801197..5eaa8ab 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: pass diff --git a/level_2/9.py b/level_2/9.py index 693804a..104ba9d 100644 --- a/level_2/9.py +++ b/level_2/9.py @@ -1,12 +1,11 @@ import datetime - from constants import ___ -def parse_receipt(raw_receipt: ___) -> ___: +def parse_receipt(raw_receipt: str) -> tuple[int, datetime.datetime, list[tuple[str, int, float]]]: pass - + if __name__ == "__main__": assert parse_receipt( raw_receipt="Кассовый чек 12 Продажа Позиции: ...", diff --git a/level_3/1.py b/level_3/1.py index 9578f5e..dd659f6 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 diff --git a/level_3/2.py b/level_3/2.py index edde766..960c61d 100644 --- a/level_3/2.py +++ b/level_3/2.py @@ -1,7 +1,8 @@ from constants import ___ +from typing import TypedDict -def calculate_total_spent_for_user(user: ___) -> ___: +def calculate_total_spent_for_user(user: dict['name': str, "age": int, 'transactions_sums': list[int]]) -> int: # попробуй тут воспользовать typing.TypedDict pass diff --git a/level_3/3.py b/level_3/3.py index 50ed15a..d61a19e 100644 --- a/level_3/3.py +++ b/level_3/3.py @@ -1,10 +1,11 @@ from constants import ___ -def create_user(user_name: ___, user_age: ___, after_created: ___) -> ___: - pass +def create_user(user_name: str, user_age: int, after_created: function) -> None: + pass + def send_test_email(user_id: int) -> None: pass diff --git a/typing_challenges b/typing_challenges new file mode 160000 index 0000000..338df8a --- /dev/null +++ b/typing_challenges @@ -0,0 +1 @@ +Subproject commit 338df8ad6def8835214e4253914d54caf10e4764