Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions sqlalchemy_utils/types/arrow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from arrow import Arrow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in an ImportError if arrow isn't installed; the current architecture is to allow for imports within the sqlalchemy_utils package but only raise an exception if a class is used but the underlying dependency isn't installed.

from ..exceptions import ImproperlyConfigured
from .enriched_datetime import ArrowDateTime
from .enriched_datetime.enriched_datetime_type import EnrichedDateTimeType
Expand Down Expand Up @@ -47,16 +48,15 @@ class Article(Base):
# 'an hour ago'

"""

cache_ok = True

def __init__(self, *args, **kwargs):
if not arrow:
raise ImproperlyConfigured(
"'arrow' package is required to use 'ArrowType'"
)

super().__init__(
datetime_processor=ArrowDateTime,
*args,
**kwargs
)
raise ImproperlyConfigured("'arrow' package is required to use 'ArrowType'")

super().__init__(datetime_processor=ArrowDateTime, *args, **kwargs)

@property
def python_type(self):
return Arrow