From: Daniele Varrazzo Date: Tue, 27 Oct 2020 18:17:25 +0000 (+0100) Subject: Force type checking with Python 3.8 X-Git-Tag: 3.0.dev0~426 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31f7ffd0192411ff2ec4ed651d0d5fb93f7723b3;p=thirdparty%2Fpsycopg.git Force type checking with Python 3.8 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 --- diff --git a/.travis.yml b/.travis.yml index 0520f9d29..5e51fb07b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/psycopg3/psycopg3/types/date.py b/psycopg3/psycopg3/types/date.py index f1a369e63..f77cf07a9 100644 --- a/psycopg3/psycopg3/types/date.py +++ b/psycopg3/psycopg3/types/date.py @@ -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 diff --git a/psycopg3/setup.cfg b/psycopg3/setup.cfg index 9e09f6267..7b7f0affb 100644 --- a/psycopg3/setup.cfg +++ b/psycopg3/setup.cfg @@ -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 db270ab32..28fb22c6e 100644 --- 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