Skip to content

Commit

Permalink
Merge pull request #4 from das7pad/bugfix/ensure-non-abstract-engine
Browse files Browse the repository at this point in the history
[shorteners] fix check for implemented `short`/`extend` methods
  • Loading branch information
blikenoother committed Feb 1, 2018
2 parents 8567dc4 + cb0cd6b commit 1ea040e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aiourlshortener/shorteners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_shorten = SourceFileLoader('aiourlshortener.shorteners.', '{}/{}'.format(_path, file)).load_module()
for attr in dir(_shorten):
tmp_cls = getattr(_shorten, attr)
if inspect.isclass(tmp_cls) and attr != 'BaseShortener' and issubclass(tmp_cls, BaseShortener):
if attr != 'BaseShortener' and inspect.isclass(tmp_cls) and issubclass(tmp_cls, BaseShortener) and not inspect.isabstract(tmp_cls):
_shorten_class[attr] = tmp_cls

__all__ = ['Shorteners', 'Shortener']
Expand All @@ -36,7 +36,7 @@ def __init__(self, engine, **kwargs):
self.shorten = None
self.expanded = None

if inspect.isclass(engine) and issubclass(engine, BaseShortener):
if inspect.isclass(engine) and issubclass(engine, BaseShortener) and not inspect.isabstract(engine):
self.engine = engine.__name__
self._class = engine
elif engine in _shorten_class:
Expand Down
4 changes: 2 additions & 2 deletions aiourlshortener/shorteners/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from abc import abstractmethod, ABC
import asyncio
from abc import abstractmethod
import aiohttp
from asyncio import coroutine

from ..exceptions import FetchError


class BaseShortener(object):
class BaseShortener(ABC):
"""
Base class for all Shorteners
"""
Expand Down

0 comments on commit 1ea040e

Please sign in to comment.