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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
env/
mypy_cache/
typing_challenges/
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
___ = None
none_type = ___
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:
pass


Expand Down
6 changes: 4 additions & 2 deletions level_1/10.py
Original file line number Diff line number Diff line change
@@ -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


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:
pass


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


Expand Down
4 changes: 2 additions & 2 deletions level_1/6.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
4 changes: 2 additions & 2 deletions level_1/7.py
Original file line number Diff line number Diff line change
@@ -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


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


Expand Down
4 changes: 2 additions & 2 deletions level_1/9.py
Original file line number Diff line number Diff line change
@@ -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


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:
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 ___


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


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


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


Expand Down
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:
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]:
pass


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да шо у тебя за прикол со скобками) В аннотациях всегда квадратные

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И пробелов после запятых не хватает

pass


Expand Down
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:
pass


Expand Down
5 changes: 2 additions & 3 deletions level_2/9.py
Original file line number Diff line number Diff line change
@@ -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 Продажа Позиции: ...",
Expand Down
3 changes: 2 additions & 1 deletion 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 Down
3 changes: 2 additions & 1 deletion level_3/2.py
Original file line number Diff line number Diff line change
@@ -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

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

Expand Down
1 change: 1 addition & 0 deletions typing_challenges
Submodule typing_challenges added at 338df8