From 456a2a8ce10693cf7d6f075480cab97f35e9dfc7 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 26 Jan 2024 15:14:48 +0000 Subject: [PATCH 1/2] Addition of MyPY This adds the requirement of type hinting as it is a type checker. I think this is good as it can make a complex codebase easier to understand. However, it does have a steep learning curve and can have issues. Probably worth discussion. --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fca6ff..6aa3d8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,3 +11,10 @@ repos: - id: flake8 args: ['--max-line-length=88', '--select=W291,W292,W293,F401'] language_version: python3 + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.3.0 + hooks: + - id: mypy + exclude: tests + args: [--strict, --ignore-missing-imports] \ No newline at end of file From 7f54bd8e36d4fe084b6486ac690049bb5e896c0e Mon Sep 17 00:00:00 2001 From: James Parkhurst Date: Fri, 2 Feb 2024 04:34:52 +0000 Subject: [PATCH 2/2] Updated mypy precommit to make it less strict --- .pre-commit-config.yaml | 2 +- src/template/__init__.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6aa3d8f..4e9f134 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,4 +17,4 @@ repos: hooks: - id: mypy exclude: tests - args: [--strict, --ignore-missing-imports] \ No newline at end of file + args: ["--ignore-missing-imports", "--implicit-optional", "--follow-imports=skip"] diff --git a/src/template/__init__.py b/src/template/__init__.py index 1ecf8c6..4d5004d 100644 --- a/src/template/__init__.py +++ b/src/template/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + def example(a, b): """ This is an example function that add the values of a and b