Skip to content

Commit 1c5b142

Browse files
authored
Merge pull request #3 from line/add-flake8
Add flake8, flake8-docstrings
2 parents a3d11a2 + be7d0ee commit 1c5b142

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1098
-818
lines changed

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def callback():
6161
def handle_message(event):
6262
line_bot_api.reply_message(
6363
event.reply_token,
64-
TextSendMessage(text=event.message.text)
65-
)
66-
64+
TextSendMessage(text=event.message.text))
6765
```
6866

6967
## API
@@ -89,8 +87,7 @@ https://devdocs.line.me/en/#reply-message
8987

9088
```python
9189
line_bot_api.reply_message(
92-
reply_token, TextSendMessage(text='Hello World!')
93-
)
90+
reply_token, TextSendMessage(text='Hello World!'))
9491
```
9592

9693
#### push_message(self, to, messages, timeout=None)
@@ -101,8 +98,7 @@ https://devdocs.line.me/en/#push-message
10198

10299
```python
103100
line_bot_api.push_message(
104-
to, TextSendMessage(text='Hello World!')
105-
)
101+
to, TextSendMessage(text='Hello World!'))
106102
```
107103

108104
#### get_profile(self, user_id, timeout=None)
@@ -163,8 +159,7 @@ https://devdocs.line.me/en/#error-response
163159
try:
164160
line_bot_api.push_message(
165161
'to',
166-
TextSendMessage(text='Hello World!')
167-
)
162+
TextSendMessage(text='Hello World!'))
168163
except linebot.LineBotApiError as e:
169164
print(e.error.message)
170165
print(e.error.details)
@@ -353,7 +348,6 @@ carousel_template_message = TemplateSendMessage(
353348
]
354349
)
355350
)
356-
357351
```
358352

359353
## Webhook
@@ -410,9 +404,7 @@ You can add handler method by using `add` decorator.
410404
def handle_message(event):
411405
line_bot_api.reply_message(
412406
event.reply_token,
413-
TextSendMessage(text=event.message.text)
414-
)
415-
407+
TextSendMessage(text=event.message.text))
416408
```
417409

418410
When event is instance of MessageEvent and event.message is instance of TextMessage, this handler method is called.
@@ -427,7 +419,6 @@ You can set default handler method by using `default` decorator.
427419
@handler.default()
428420
def default(event):
429421
print(event)
430-
431422
```
432423

433424
There is no handler for event, this default handler method is called.

examples/flask-echo/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- coding: utf-8 -*-
2+
23
# Licensed under the Apache License, Version 2.0 (the "License"); you may
34
# not use this file except in compliance with the License. You may obtain
45
# a copy of the License at
56
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
78
#
89
# Unless required by applicable law or agreed to in writing, software
910
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@@ -18,7 +19,6 @@
1819
from argparse import ArgumentParser
1920

2021
from flask import Flask, request, abort
21-
2222
from linebot import (
2323
LineBotApi, WebhookParser
2424
)
@@ -47,7 +47,6 @@
4747

4848
@app.route("/callback", methods=['POST'])
4949
def callback():
50-
# get X-Line-Signature header value
5150
signature = request.headers['X-Line-Signature']
5251

5352
# get request body as text

examples/flask-echo/app_with_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- coding: utf-8 -*-
2+
23
# Licensed under the Apache License, Version 2.0 (the "License"); you may
34
# not use this file except in compliance with the License. You may obtain
45
# a copy of the License at
56
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
78
#
89
# Unless required by applicable law or agreed to in writing, software
910
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
@@ -16,7 +17,6 @@
1617
from argparse import ArgumentParser
1718

1819
from flask import Flask, request, abort
19-
2020
from linebot import (
2121
LineBotApi, WebhookHandler
2222
)

examples/flask-kitchensink/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
23
# Licensed under the Apache License, Version 2.0 (the "License"); you may
34
# not use this file except in compliance with the License. You may obtain
45
# a copy of the License at
@@ -187,7 +188,7 @@ def handle_sticker_message(event):
187188

188189
# Other Message Type
189190
@handler.add(MessageEvent, message=(ImageMessage, VideoMessage, AudioMessage))
190-
def handle_sticker_message(event):
191+
def handle_content_message(event):
191192
if isinstance(event.message, ImageMessage):
192193
ext = '.jpg'
193194
elif isinstance(event.message, VideoMessage):
@@ -239,7 +240,7 @@ def handle_postback(event):
239240

240241

241242
@handler.add(BeaconEvent)
242-
def handle_leave(event):
243+
def handle_beacon(event):
243244
line_bot_api.reply_message(
244245
event.reply_token,
245246
TextSendMessage(text='Got beacon event. hwid=' + event.beacon.hwid))

examples/simple-server-echo/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
23
# Licensed under the Apache License, Version 2.0 (the "License"); you may
34
# not use this file except in compliance with the License. You may obtain
45
# a copy of the License at
@@ -17,7 +18,6 @@
1718
from argparse import ArgumentParser
1819

1920
from builtins import bytes
20-
2121
from linebot import (
2222
LineBotApi, WebhookParser
2323
)

linebot/__about__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# -*- coding: utf-8 -*-
2-
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
34
# not use this file except in compliance with the License. You may obtain
45
# a copy of the License at
56
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
78
#
89
# Unless required by applicable law or agreed to in writing, software
9-
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1011
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1112
# License for the specific language governing permissions and limitations
1213
# under the License.
1314

15+
"""Meta data of line-bot-sdk."""
16+
1417
from __future__ import unicode_literals
1518

1619
__version__ = '0.1.0'

linebot/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
# -*- coding: utf-8 -*-
2+
23
# Licensed under the Apache License, Version 2.0 (the "License"); you may
34
# not use this file except in compliance with the License. You may obtain
45
# a copy of the License at
56
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
78
#
89
# Unless required by applicable law or agreed to in writing, software
910
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1011
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1112
# License for the specific language governing permissions and limitations
1213
# under the License.
1314

15+
"""linebot package."""
16+
1417
from __future__ import unicode_literals
1518

16-
from .__about__ import (
19+
from .__about__ import ( # noqa
1720
__version__
1821
)
19-
from .api import (
22+
from .api import ( # noqa
2023
LineBotApi,
2124
)
22-
from .http_client import (
25+
from .http_client import ( # noqa
2326
HttpClient,
2427
RequestsHttpClient,
2528
HttpResponse,
2629
)
27-
from .webhook import (
30+
from .webhook import ( # noqa
2831
SignatureValidator,
2932
WebhookParser,
3033
WebhookHandler,

0 commit comments

Comments
 (0)