From 0e1f74a7556dc95721e9c20b397f8706568a81ac Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 13 May 2022 09:23:45 -0500 Subject: [PATCH 1/2] Run mypy during pre-commit --- .pre-commit-config.yaml | 14 ++++++++++++++ jepler_udecimal/__init__.py | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13e2c37..1627ac6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,3 +30,17 @@ repos: name: lint (code) types: [python] exclude: "^(docs/|examples/|setup.py$)" +- repo: local + hooks: + - id: mypy + name: mypy + entry: "mypy --no-warn-unused-ignores jepler_udecimal" + language: python + additional_dependencies: ["mypy==0.910"] + types: [python] + # use require_serial so that script + # is only called once per commit + require_serial: true + # Print the number of files as a sanity-check + verbose: true + pass_filenames: false diff --git a/jepler_udecimal/__init__.py b/jepler_udecimal/__init__.py index 4ed7c23..56598ab 100644 --- a/jepler_udecimal/__init__.py +++ b/jepler_udecimal/__init__.py @@ -141,7 +141,7 @@ DecimalTuple = _namedtuple("DecimalTuple", "sign digits exponent") except ImportError: - DecimalTuple = lambda *args: args + DecimalTuple = lambda *args: args # type: ignore # Rounding ROUND_DOWN = "ROUND_DOWN" @@ -3574,7 +3574,7 @@ def _regard_flags(self, *flags): self._ignored_flags.remove(flag) # We inherit object.__hash__, so we must deny this explicitly - __hash__ = None + __hash__ = None # type: ignore def Etiny(self): """Returns Etiny (= Emin - prec + 1)""" @@ -5372,7 +5372,7 @@ def _convert_for_comparison(self, other, equality_op=False): try: import re except: - import ure as re + import ure as re # type: ignore _parser = re.compile( # A numeric string consists of: r"([-+])?" # an optional sign, followed by either... # 1 From 22a4a749b16841b1438239602ddb59d6286bb8e4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 13 May 2022 09:39:18 -0500 Subject: [PATCH 2/2] bump black version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1627ac6..295df0a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/python/black - rev: 22.1.0 + rev: 22.3.0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool