summaryrefslogtreecommitdiff
path: root/dateutil/parser/_parser.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-01-11 18:08:59 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2018-01-11 18:08:59 -0800
commit82e723c85262645eaa0521114066ec0f202e433e (patch)
treefee357e0b695818014c1bca46d9ddce390204aba /dateutil/parser/_parser.py
parent13622bcdb14f28266529473c16dab2dfb13f4245 (diff)
downloaddateutil-git-82e723c85262645eaa0521114066ec0f202e433e.tar.gz
Prefer builtin callable() over isinstance(..., collections.Callable)
Available on all supported Python versions. https://docs.python.org/3/library/functions.html#callable
Diffstat (limited to 'dateutil/parser/_parser.py')
-rw-r--r--dateutil/parser/_parser.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py
index baac3fe..1391437 100644
--- a/dateutil/parser/_parser.py
+++ b/dateutil/parser/_parser.py
@@ -30,7 +30,6 @@ Additional resources about date/time string formats can be found below:
"""
from __future__ import unicode_literals
-import collections
import datetime
import re
import string
@@ -1107,7 +1106,7 @@ class parser(object):
return skipped_tokens
def _build_tzinfo(self, tzinfos, tzname, tzoffset):
- if isinstance(tzinfos, collections.Callable):
+ if callable(tzinfos):
tzdata = tzinfos(tzname, tzoffset)
else:
tzdata = tzinfos.get(tzname)
@@ -1124,8 +1123,7 @@ class parser(object):
return tzinfo
def _build_tzaware(self, naive, res, tzinfos):
- if (isinstance(tzinfos, collections.Callable) or
- (tzinfos and res.tzname in tzinfos)):
+ if (callable(tzinfos) or (tzinfos and res.tzname in tzinfos)):
tzinfo = self._build_tzinfo(tzinfos, res.tzname, res.tzoffset)
aware = naive.replace(tzinfo=tzinfo)
aware = self._assign_tzname(aware, res.tzname)