Skip to content

Commit d859aba

Browse files
author
Tasuku OKUDA
committed
Change classes need some implements to use abc module
1 parent 9bcd03f commit d859aba

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

linebot/http_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
from abc import ABCMeta, abstractmethod
5+
from future.utils import with_metaclass
46
import requests
57

68

7-
class HttpClient(object):
9+
class HttpClient(with_metaclass(ABCMeta)):
810
DEFAULT_TIMEOUT = 5
911

1012
def __init__(self, timeout=DEFAULT_TIMEOUT):
@@ -17,6 +19,7 @@ def __init__(self, timeout=DEFAULT_TIMEOUT):
1719

1820
self.timeout = timeout
1921

22+
@abstractmethod
2023
def get(self, url, headers=None, params=None, timeout=None):
2124
"""GET request
2225
@@ -30,6 +33,7 @@ def get(self, url, headers=None, params=None, timeout=None):
3033
"""
3134
raise NotImplementedError
3235

36+
@abstractmethod
3337
def get_stream(self, url, headers=None, params=None, timeout=None,
3438
chunk_size=1024, decode_unicode=False):
3539
"""GET request. response is chunk content.
@@ -45,6 +49,7 @@ def get_stream(self, url, headers=None, params=None, timeout=None,
4549
"""
4650
raise NotImplementedError
4751

52+
@abstractmethod
4853
def post(self, url, headers=None, data=None, timeout=None):
4954
"""POST request.
5055

linebot/models/sources.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
from __future__ import unicode_literals
33

44
from .base import Base
5+
from abc import ABCMeta, abstractproperty
6+
from future.utils import with_metaclass
57

68

7-
class Source(Base):
9+
class Source(with_metaclass(ABCMeta, Base)):
810
"""Base Class of Source"""
911

1012
def __init__(self, **kwargs):
1113
super(Source, self).__init__(**kwargs)
1214
self.type = None
1315

14-
@property
16+
@abstractproperty
1517
def sender_id(self):
1618
raise NotImplementedError
1719

0 commit comments

Comments
 (0)