Remove type hints - not supported in Python 3.5

This commit is contained in:
Itai Shirav 2020-06-23 11:26:43 +03:00
parent f98dead1ab
commit c45bd07cea

View File

@ -1,6 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import datetime import datetime
from typing import List, Union
import iso8601 import iso8601
import pytz import pytz
from calendar import timegm from calendar import timegm
@ -95,7 +94,7 @@ class Field(FunctionOperatorsMixin):
sql += self._extra_params(db) sql += self._extra_params(db)
return sql return sql
def get_db_type_args(self) -> List[str]: def get_db_type_args(self):
"""Returns field type arguments""" """Returns field type arguments"""
return [] return []
@ -197,14 +196,14 @@ class DateTimeField(Field):
db_type = 'DateTime' db_type = 'DateTime'
def __init__(self, default=None, alias=None, materialized=None, readonly=None, codec=None, def __init__(self, default=None, alias=None, materialized=None, readonly=None, codec=None,
timezone: Union[BaseTzInfo, str] = None): timezone=None):
super().__init__(default, alias, materialized, readonly, codec) super().__init__(default, alias, materialized, readonly, codec)
# assert not timezone, 'Temporarily field timezone is not supported' # assert not timezone, 'Temporarily field timezone is not supported'
if timezone: if timezone:
timezone = timezone if isinstance(timezone, BaseTzInfo) else pytz.timezone(timezone) timezone = timezone if isinstance(timezone, BaseTzInfo) else pytz.timezone(timezone)
self.timezone: BaseTzInfo = timezone self.timezone = timezone
def get_db_type_args(self) -> List[str]: def get_db_type_args(self):
args = [] args = []
if self.timezone: if self.timezone:
args.append(escape(self.timezone.zone)) args.append(escape(self.timezone.zone))
@ -246,18 +245,18 @@ class DateTime64Field(DateTimeField):
db_type = 'DateTime64' db_type = 'DateTime64'
def __init__(self, default=None, alias=None, materialized=None, readonly=None, codec=None, def __init__(self, default=None, alias=None, materialized=None, readonly=None, codec=None,
timezone: Union[BaseTzInfo, str] = None, precision: int = 6): timezone=None, precision=6):
super().__init__(default, alias, materialized, readonly, codec, timezone) super().__init__(default, alias, materialized, readonly, codec, timezone)
assert precision is None or isinstance(precision, int), 'Precision must be int type' assert precision is None or isinstance(precision, int), 'Precision must be int type'
self.precision = precision self.precision = precision
def get_db_type_args(self) -> List[str]: def get_db_type_args(self):
args = [str(self.precision)] args = [str(self.precision)]
if self.timezone: if self.timezone:
args.append(escape(self.timezone.zone)) args.append(escape(self.timezone.zone))
return args return args
def to_db_string(self, value: datetime.datetime, quote=True): def to_db_string(self, value, quote=True):
""" """
Returns the field's value prepared for writing to the database Returns the field's value prepared for writing to the database