]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Force type checking with Python 3.8
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 27 Oct 2020 18:17:25 +0000 (19:17 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 28 Oct 2020 03:19:24 +0000 (04:19 +0100)
Aligning Travis with my current dev environment to avoid cases where
it's not possible to type-check consistently with different Python
versions.

See https://github.com/python/mypy/issues/9652

.travis.yml
psycopg3/psycopg3/types/date.py
psycopg3/setup.cfg
tox.ini

index 0520f9d29578b7652598706642206c3b649ae1e3..5e51fb07b577dba41388b32d4f33dc6c7fabe57c 100644 (file)
@@ -12,17 +12,17 @@ matrix:
     - env:
         - TOXENV=black
         - TOXDIR=.
-      python: 3.6
+      python: 3.8
 
     - env:
         - TOXENV=flake8
         - TOXDIR=.
-      python: 3.6
+      python: 3.8
 
     - env:
         - TOXENV=mypy
         - TOXDIR=.
-      python: 3.6
+      python: 3.8
 
     - python: 3.6
       addons:
index f1a369e63737f049aa03613f196b46f698157bbf..f77cf07a92cb31b10e2bfe5a65457c2908dd5230 100644 (file)
@@ -184,6 +184,11 @@ class TimeTzLoader(TimeLoader):
 
     def __init__(self, oid: int, context: AdaptContext):
         if sys.version_info < (3, 7):
+            # fun fact: mypy doesn't complain about this on Python 3.8
+            # but it does on Python 3.6. Adding "# type: ignore[assignment]"
+            # will result in Python 3.6 passing but 3.8 complaining of unused
+            # assignment. You cannot win.
+            # https://github.com/python/mypy/issues/9652
             self.load = self._load_py36
 
         super().__init__(oid, context)
@@ -201,7 +206,9 @@ class TimeTzLoader(TimeLoader):
 
         return dt.time().replace(tzinfo=dt.tzinfo)
 
-    def _load_py36(self, data: bytes) -> time:
+    def _load_py36(
+        self, data: bytes, __decode: DecodeFunc = _decode_ascii
+    ) -> time:
         # Drop seconds from timezone for Python 3.6
         # Also, Python 3.6 doesn't support HHMM, only HH:MM
         if data[-6] in (43, 45):  # +-HH:MM -> +-HHMM
@@ -309,7 +316,9 @@ class TimestamptzLoader(TimestampLoader):
 
         return super().load(data)
 
-    def _load_py36(self, data: bytes) -> datetime:
+    def _load_py36(
+        self, data: bytes, __decode: DecodeFunc = _decode_ascii
+    ) -> datetime:
         # Drop seconds from timezone for Python 3.6
         # Also, Python 3.6 doesn't support HHMM, only HH:MM
         tzsep = (43, 45)  # + and - bytes
index 9e09f62677e24de2c79e0f96e10fdfeafd896c1a..7b7f0affb2e7804804efdc72838447730299fb7b 100644 (file)
@@ -42,4 +42,4 @@ dev =
     tox
     black
     flake8 >= 3.8, < 3.9
-    mypy >= 0.782
+    mypy >= 0.790
diff --git a/tox.ini b/tox.ini
index db270ab32f46f7e07b3c4687a1e3d0e8e6a9cc66..28fb22c6e3f6fd0a598de54507ef252a27946848 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -14,7 +14,7 @@ skip_install = true
 
 [testenv:mypy]
 commands = mypy
-deps = mypy >= 0.782
+deps = mypy >= 0.790
 changedir = psycopg3
 skip_install = true