Исправлены type hints у декоратора log
このコミットが含まれているのは:
コミット
43749cab59
|
@ -69,14 +69,8 @@ def gen_client(output_client_filename):
|
||||||
code = code.replace(f'self.{method}(', f'await self.{method}(')
|
code = code.replace(f'self.{method}(', f'await self.{method}(')
|
||||||
|
|
||||||
# specific cases
|
# specific cases
|
||||||
code = code.replace(
|
code = code.replace('self.users_playlists_change(', 'await self.users_playlists_change(')
|
||||||
'self.users_playlists_change(',
|
code = code.replace('self.rotor_station_feedback(', 'await self.rotor_station_feedback(')
|
||||||
'await self.users_playlists_change('
|
|
||||||
)
|
|
||||||
code = code.replace(
|
|
||||||
'self.rotor_station_feedback(',
|
|
||||||
'await self.rotor_station_feedback('
|
|
||||||
)
|
|
||||||
code = code.replace('return DownloadInfo.de_list', 'return await DownloadInfo.de_list_async')
|
code = code.replace('return DownloadInfo.de_list', 'return await DownloadInfo.de_list_async')
|
||||||
|
|
||||||
code = DISCLAIMER + code
|
code = DISCLAIMER + code
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union, TypeVar, Callable, Any
|
||||||
|
|
||||||
from yandex_music import (
|
from yandex_music import (
|
||||||
Album,
|
Album,
|
||||||
|
@ -55,12 +55,14 @@ de_list = {
|
||||||
|
|
||||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||||
|
|
||||||
|
F = TypeVar('F', bound=Callable[..., Any])
|
||||||
|
|
||||||
def log(method):
|
|
||||||
|
def log(method: F) -> F:
|
||||||
logger = logging.getLogger(method.__module__)
|
logger = logging.getLogger(method.__module__)
|
||||||
|
|
||||||
@functools.wraps(method)
|
@functools.wraps(method)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs) -> Any:
|
||||||
logger.debug(f'Entering: {method.__name__}')
|
logger.debug(f'Entering: {method.__name__}')
|
||||||
|
|
||||||
result = method(*args, **kwargs)
|
result = method(*args, **kwargs)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union, TypeVar, Callable, Any
|
||||||
|
|
||||||
from yandex_music import (
|
from yandex_music import (
|
||||||
Album,
|
Album,
|
||||||
|
@ -59,12 +59,14 @@ de_list = {
|
||||||
|
|
||||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||||
|
|
||||||
|
F = TypeVar('F', bound=Callable[..., Any])
|
||||||
|
|
||||||
def log(method):
|
|
||||||
|
def log(method: F) -> F:
|
||||||
logger = logging.getLogger(method.__module__)
|
logger = logging.getLogger(method.__module__)
|
||||||
|
|
||||||
@functools.wraps(method)
|
@functools.wraps(method)
|
||||||
async def wrapper(*args, **kwargs):
|
async def wrapper(*args, **kwargs) -> Any:
|
||||||
logger.debug(f'Entering: {method.__name__}')
|
logger.debug(f'Entering: {method.__name__}')
|
||||||
|
|
||||||
result = await method(*args, **kwargs)
|
result = await method(*args, **kwargs)
|
||||||
|
|
読み込み中…
新しいイシューから参照