]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Reformat lines for pep8 test compliance 4986/head
authorGord Thompson <gord@gordthompson.com>
Wed, 20 Nov 2019 23:25:24 +0000 (16:25 -0700)
committerGord Thompson <gord@gordthompson.com>
Wed, 20 Nov 2019 23:25:24 +0000 (16:25 -0700)
lib/sqlalchemy/dialects/mssql/pyodbc.py
test/dialect/mssql/test_types.py

index de411d8f8f80fbb139106d452bd1109d68021ed5..21793881ec008a77f4fb9fe1c6932ffb103328e3 100644 (file)
@@ -118,7 +118,7 @@ in order to use this flag::
 
 """  # noqa
 
-from datetime import datetime, timezone, timedelta
+from datetime import datetime, timedelta, timezone
 import decimal
 import re
 import struct
@@ -370,13 +370,15 @@ class MSDialect_pyodbc(PyODBCConnector, MSDialect):
 
             # output converter function for datetimeoffset
             def _handle_datetimeoffset(dto_value):
-                # ref: https://github.com/mkleehammer/pyodbc/issues/134#issuecomment-281739794
-                tup = struct.unpack("<6hI2h", dto_value)  # e.g., (2017, 3, 16, 10, 35, 18, 0, -6, 0)
-                return datetime(tup[0], tup[1], tup[2], tup[3], tup[4], tup[5], tup[6] // 1000,
-                                timezone(timedelta(hours=tup[7], minutes=tup[8])))
+                tup = struct.unpack("<6hI2h", dto_value)
+                return datetime(tup[0], tup[1], tup[2],
+                                tup[3], tup[4], tup[5], tup[6] // 1000,
+                                timezone(timedelta(hours=tup[7],
+                                                   minutes=tup[8])))
 
             odbc_SQL_SS_TIMESTAMPOFFSET = -155  # as defined in SQLNCLI.h
-            conn.add_output_converter(odbc_SQL_SS_TIMESTAMPOFFSET, _handle_datetimeoffset)
+            conn.add_output_converter(odbc_SQL_SS_TIMESTAMPOFFSET,
+                                      _handle_datetimeoffset)
 
         return on_connect
 
index 2b6d4b669e9ee418a029de9c3b781c45619cf4ae..650fb6786cc6b9c838358c596b591ea27d9f740e 100644 (file)
@@ -730,14 +730,16 @@ class TypeRoundTripTest(
         d2 = datetime.datetime(2007, 10, 30, 11, 2, 32)
         dto = datetime.datetime(2007, 10, 30, 11, 2, 32, 0,
                                 datetime.timezone(datetime.timedelta(hours=1)))
-        t.insert().execute(adate=d1, adatetime=d2, atime=t1, adatetimeoffset=dto)
+        t.insert().execute(adate=d1, adatetime=d2, atime=t1,
+                           adatetimeoffset=dto)
 
         # NOTE: this previously passed 'd2' for "adate" even though
         # "adate" is a date column; we asserted that it truncated w/o issue.
         # As of pyodbc 4.0.22, this is no longer accepted, was accepted
         # in 4.0.21.  See also the new pyodbc assertions regarding numeric
         # precision.
-        t.insert().execute(adate=d1, adatetime=d2, atime=d2, adatetimeoffset=dto)
+        t.insert().execute(adate=d1, adatetime=d2, atime=d2,
+                           adatetimeoffset=dto)
 
         x = t.select().execute().fetchall()[0]
         self.assert_(x.adate.__class__ == datetime.date)
@@ -747,10 +749,12 @@ class TypeRoundTripTest(
 
         t.delete().execute()
 
-        t.insert().execute(adate=d1, adatetime=d2, atime=t1, adatetimeoffset=dto)
+        t.insert().execute(adate=d1, adatetime=d2, atime=t1,
+                           adatetimeoffset=dto)
 
         eq_(
-            select([t.c.adate, t.c.atime, t.c.adatetime, t.c.adatetimeoffset], t.c.adate == d1)
+            select([t.c.adate, t.c.atime, t.c.adatetime, t.c.adatetimeoffset],
+                   t.c.adate == d1)
             .execute()
             .fetchall(),
             [(d1, t1, d2, dto)],