Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion level_1/1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def is_user_banned(user_id: ___) -> ___:
def is_user_banned(user_id: int) -> bool | None:
pass


Expand Down
2 changes: 1 addition & 1 deletion level_1/10.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def stringify(value: ___) -> ___:
def stringify(value: str | int | float | None) -> str | None:
pass


Expand Down
2 changes: 1 addition & 1 deletion level_1/2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def is_adult(age: ___, country_name: ___) -> ___:
def is_adult(age: int, country_name: str) -> bool | None:
pass


Expand Down
8 changes: 5 additions & 3 deletions level_1/3.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion level_1/4.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from constants import ___


def calculate_age(date_of_birth: ___) -> ___:
def calculate_age(date_of_birth: datetime.date) -> int | None:
pass


Expand Down
2 changes: 1 addition & 1 deletion level_1/5.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def is_correct_email(raw_email: ___) -> ___:
def is_correct_email(raw_email: str) -> bool | None:
pass


Expand Down
8 changes: 5 additions & 3 deletions level_1/6.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions level_1/7.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion level_1/8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion level_1/9.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def is_correct_int(raw_int: ___) -> ___:
def is_correct_int(raw_int: str | None) -> bool | None:
pass


Expand Down
2 changes: 1 addition & 1 deletion level_2/1.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion level_2/10.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
5 changes: 3 additions & 2 deletions level_2/2.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions level_2/3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
2 changes: 1 addition & 1 deletion level_2/4.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def ban_users(users_ids: ___) -> ___:
def ban_users(users_ids: set[int]) -> int | None:
pass


Expand Down
2 changes: 1 addition & 1 deletion level_2/5.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from constants import ___


def get_current_user() -> ___:
def get_current_user() -> tuple[str, int, str] | None:
pass


Expand Down
2 changes: 1 addition & 1 deletion level_2/6.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
5 changes: 3 additions & 2 deletions level_2/7.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion level_2/8.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion level_2/9.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
9 changes: 6 additions & 3 deletions level_3/1.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
10 changes: 8 additions & 2 deletions level_3/2.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion level_3/3.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down