From 82e723c85262645eaa0521114066ec0f202e433e Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 11 Jan 2018 18:08:59 -0800 Subject: Prefer builtin callable() over isinstance(..., collections.Callable) Available on all supported Python versions. https://docs.python.org/3/library/functions.html#callable --- dateutil/parser/_parser.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'dateutil/parser/_parser.py') 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) -- cgit v1.2.1