This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Protocol | |
| class MessageCallback(Protocol): | |
| __name__: str | |
| def __call__( | |
| self, | |
| message: str, | |
| size: int, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| # DEFAULT_LOG_FORMAT = "[%(asctime)s.%(msecs)03d] %(funcName)20s %(module)s:%(lineno)d %(levelname)-8s - %(message)s" | |
| DEFAULT_LOG_FORMAT = ( | |
| "%(funcName)10s %(module)s:%(lineno)d %(levelname)-8s - %(message)s" | |
| ) | |
| def configure_logging(level: int = logging.INFO) -> None: | |
| logging.basicConfig( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Tested on macOS 11.5 Big Sur | |
| SIP disabled | |
| admin@MBP-Suren ~ % csrutil status | |
| System Integrity Protection status: disabled. | |
| run: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [tool.mypy] | |
| strict = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SOME_SENTENCE = input("Enter a sentence: ") | |
| from collections import defaultdict | |
| from collections.abc import Iterable | |
| SOME_SENTENCE = ( | |
| "The cat sat on the mat, " | |
| "and the cat played with the mat " | |
| "while the cat watched the sun." | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| # DEFAULT_LOG_FORMAT = "[%(asctime)s.%(msecs)03d] %(funcName)20s %(module)s:%(lineno)d %(levelname)-8s - %(message)s" | |
| DEFAULT_LOG_FORMAT = ( | |
| "%(funcName)10s %(module)s:%(lineno)d %(levelname)-8s - %(message)s" | |
| ) | |
| def configure_logging(level: int = logging.INFO) -> None: | |
| logging.basicConfig( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [tool.mypy] | |
| strict = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [tool.mypy] | |
| strict = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import TypeVar, Sequence | |
| T = TypeVar("T") | |
| def repeat(val: T, times: int) -> list[T]: | |
| return [val] * times | |
| def get_first_element(items: Sequence[T]) -> T: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Based on https://github.com/tough-dev-school/education-backend/blob/master/src/core/services.py | |
| """ | |
| from abc import ABC, abstractmethod | |
| from collections.abc import Callable, Sequence | |
| from typing import Any, Generic, TypeVar | |
| ReturnType = TypeVar('ReturnType') |