Skip to content

Commit 7565aae

Browse files
committed
lint対応
1 parent 4a77982 commit 7565aae

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

plugins/analyze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"""
44

55
from typing import Callable
6+
from functools import partial
67
from library.clientclass import BaseClient
78
from plugins import hato
8-
from functools import partial
99

1010

1111
def analyze_message(message: str) -> Callable[[BaseClient], None]:

plugins/hato.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from enum import Enum, auto
1010
from logging import getLogger
1111
from tempfile import NamedTemporaryFile
12-
from typing import List, Callable, Union
12+
from typing import List, Callable, Union, Any
1313
import requests
1414
from git import Repo
1515
from git.exc import InvalidGitRepositoryError, GitCommandNotFound
@@ -18,30 +18,36 @@
1818

1919
import slackbot_settings as conf
2020
from library.vocabularydb \
21-
import get_vocabularys, add_vocabulary, show_vocabulary, delete_vocabulary, show_random_vocabulary
21+
import get_vocabularys, add_vocabulary, show_vocabulary, \
22+
delete_vocabulary, show_random_vocabulary
2223
from library.earthquake import generate_quake_info_for_slack, get_quake_list
2324
from library.hukidasi import generator
2425
from library.geo import get_geo_data
2526
from library.hatokaraage import hato_ha_karaage
2627
from library.clientclass import BaseClient
2728
from library.jma_amesh import jma_amesh
2829
from library.omikuji import OmikujiResult, OmikujiResults, draw as omikuji_draw
29-
logger = getLogger(__name__)
3030

31+
from mypy_extensions import VarArg
32+
33+
logger = getLogger(__name__)
3134

32-
def action(plugin_name: str, with_client: bool = False) -> Callable[[BaseClient, ...], None]:
35+
def action(plugin_name: str, with_client: bool = False):
3336
"""
3437
アクション定義メソッドに使うデコレータ
38+
3539
"""
3640

37-
def _action(func: Callable[[BaseClient, ...], Union[str, None]]):
41+
def _action(func: Callable[[BaseClient, VarArg(Any)], Union[str, None]]):
3842
def wrapper(client: BaseClient, *args, **kwargs):
3943
logger.debug("%s called '%s'", client.get_send_user(), plugin_name)
4044
logger.debug("%s app called '%s'", client.get_type(), plugin_name)
4145
if with_client:
4246
func(client, *args, **kwargs)
4347
else:
44-
client.post(func(*args, **kwargs))
48+
return_val = func(*args, **kwargs)
49+
if isinstance(return_val, str):
50+
client.post(return_val)
4551

4652
return wrapper
4753
return _action
@@ -236,8 +242,7 @@ def altitude(place: str):
236242
try:
237243
coordinates = [str(float(p)) for p in reversed(place_list)]
238244
except ValueError:
239-
client.post('引数が正しくないっぽ......')
240-
return None
245+
return '引数が正しくないっぽ......'
241246

242247
place_name = ', '.join(reversed(coordinates))
243248
else:

0 commit comments

Comments
 (0)