diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 01:14:26 -0500 |
---|---|---|
committer | mike bayer <mike_mp@zzzcomputing.com> | 2019-01-06 17:34:50 +0000 |
commit | 1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch) | |
tree | 28e725c5c8188bd0cfd133d1e268dbca9b524978 /lib/sqlalchemy/processors.py | |
parent | 404e69426b05a82d905cbb3ad33adafccddb00dd (diff) | |
download | sqlalchemy-1e1a38e7801f410f244e4bbb44ec795ae152e04e.tar.gz |
Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits
applied at all.
The black run will format code consistently, however in
some cases that are prevalent in SQLAlchemy code it produces
too-long lines. The too-long lines will be resolved in the
following commit that will resolve all remaining flake8 issues
including shadowed builtins, long lines, import order, unused
imports, duplicate imports, and docstring issues.
Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
Diffstat (limited to 'lib/sqlalchemy/processors.py')
-rw-r--r-- | lib/sqlalchemy/processors.py | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/lib/sqlalchemy/processors.py b/lib/sqlalchemy/processors.py index 860a55b8f..46d5dcbc6 100644 --- a/lib/sqlalchemy/processors.py +++ b/lib/sqlalchemy/processors.py @@ -32,20 +32,30 @@ def str_to_datetime_processor_factory(regexp, type_): try: m = rmatch(value) except TypeError: - raise ValueError("Couldn't parse %s string '%r' " - "- value is not a string." % - (type_.__name__, value)) + raise ValueError( + "Couldn't parse %s string '%r' " + "- value is not a string." % (type_.__name__, value) + ) if m is None: - raise ValueError("Couldn't parse %s string: " - "'%s'" % (type_.__name__, value)) + raise ValueError( + "Couldn't parse %s string: " + "'%s'" % (type_.__name__, value) + ) if has_named_groups: groups = m.groupdict(0) - return type_(**dict(list(zip( - iter(groups.keys()), - list(map(int, iter(groups.values()))) - )))) + return type_( + **dict( + list( + zip( + iter(groups.keys()), + list(map(int, iter(groups.values()))), + ) + ) + ) + ) else: return type_(*list(map(int, m.groups(0)))) + return process @@ -61,6 +71,7 @@ def py_fallback(): # len part is safe: it is done that way in the normal # 'xx'.decode(encoding) code path. return decoder(value, errors)[0] + return process def to_conditional_unicode_processor_factory(encoding, errors=None): @@ -76,6 +87,7 @@ def py_fallback(): # len part is safe: it is done that way in the normal # 'xx'.decode(encoding) code path. return decoder(value, errors)[0] + return process def to_decimal_processor_factory(target_class, scale): @@ -86,6 +98,7 @@ def py_fallback(): return None else: return target_class(fstring % value) + return process def to_float(value): @@ -107,22 +120,30 @@ def py_fallback(): return bool(value) DATETIME_RE = re.compile( - r"(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)(?:\.(\d+))?") + r"(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)(?:\.(\d+))?" + ) TIME_RE = re.compile(r"(\d+):(\d+):(\d+)(?:\.(\d+))?") DATE_RE = re.compile(r"(\d+)-(\d+)-(\d+)") - str_to_datetime = str_to_datetime_processor_factory(DATETIME_RE, - datetime.datetime) + str_to_datetime = str_to_datetime_processor_factory( + DATETIME_RE, datetime.datetime + ) str_to_time = str_to_datetime_processor_factory(TIME_RE, datetime.time) str_to_date = str_to_datetime_processor_factory(DATE_RE, datetime.date) return locals() + try: - from sqlalchemy.cprocessors import UnicodeResultProcessor, \ - DecimalResultProcessor, \ - to_float, to_str, int_to_boolean, \ - str_to_datetime, str_to_time, \ - str_to_date + from sqlalchemy.cprocessors import ( + UnicodeResultProcessor, + DecimalResultProcessor, + to_float, + to_str, + int_to_boolean, + str_to_datetime, + str_to_time, + str_to_date, + ) def to_unicode_processor_factory(encoding, errors=None): if errors is not None: @@ -144,5 +165,6 @@ try: # return Decimal('5'). These are equivalent of course. return DecimalResultProcessor(target_class, "%%.%df" % scale).process + except ImportError: globals().update(py_fallback()) |