From 5ec2940bfbdf4e4c194179ce43227956d40621bf Mon Sep 17 00:00:00 2001 From: Johannes Ernst Date: Tue, 24 Sep 2024 10:49:25 -0700 Subject: [PATCH 1/2] Remote --ignore-missing-import from mypy options in .pre-commit-config.yaml and add more surgical disable comment into the source Make Makefile-invoked mypy options consistent with those in .pre-commit-config.yaml --- .pre-commit-config.yaml | 1 - Makefile | 9 +++++---- src/feditest/nodedrivers/mastodon/__init__.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c88aa9..0ce63a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,6 @@ repos: - id: mypy files: src args: - - "--ignore-missing-imports" - "--namespace-packages" - "--explicit-package-bases" - "--install-types" diff --git a/Makefile b/Makefile index 98e3cce..9a12440 100644 --- a/Makefile +++ b/Makefile @@ -30,15 +30,16 @@ $(VENV) : $(PYTHON) -mvenv $(VENV) $(VENV)/bin/pip install ruff mypy pylint -lint : venv +lint : build $(VENV)/bin/ruff check src - $(VENV)/bin/mypy src - # $(VENV)/bin/pylint src + MYPYPATH=src $(VENV)/bin/mypy --namespace-packages --explicit-package-bases --install-types --non-interactive src + @# These options should be the same flags as in .pre-commit-config.yml + @# MYPYPATH is needed because apparently some type checking ignores the directory option given as command-line argument + @# $(VENV)/bin/pylint src test : venv $(VENV)/bin/pytest -v - release : @which $(PYTHON) || ( echo 'No executable called "python". Append your python to the make command, like "make PYTHON=your-python"' && false ) [[ -d venv.release ]] && rm -rf venv.release || true diff --git a/src/feditest/nodedrivers/mastodon/__init__.py b/src/feditest/nodedrivers/mastodon/__init__.py index 2f8288e..db60040 100644 --- a/src/feditest/nodedrivers/mastodon/__init__.py +++ b/src/feditest/nodedrivers/mastodon/__init__.py @@ -44,11 +44,11 @@ m = sys.modules.pop("mastodon") try: mastodon_api = importlib.import_module("mastodon") - from mastodon_api import AttribAccessDict, Mastodon + from mastodon_api import AttribAccessDict, Mastodon # type: ignore finally: sys.modules["mastodon"] = m else: - from mastodon import AttribAccessDict, Mastodon + from mastodon import AttribAccessDict, Mastodon # type: ignore VERIFY_API_TLS_CERTIFICATE_PAR = TestPlanNodeParameter( From fd9c47c7ced0b5af4604418877e870bf8801c2fa Mon Sep 17 00:00:00 2001 From: Johannes Ernst Date: Tue, 24 Sep 2024 11:21:01 -0700 Subject: [PATCH 2/2] Bump mypy version Put --ignore-missing-imports back into .pre-commit-config; lots of errors without although this flag is not needed when mypy is invoked outside of pre-commit --- .pre-commit-config.yaml | 3 ++- Makefile | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ce63a5..ff27a90 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,11 +53,12 @@ repos: always_run: true - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy files: src args: + - "--ignore-missing-imports" # Not managing to get it to work from pre-commit without this flag - "--namespace-packages" - "--explicit-package-bases" - "--install-types" diff --git a/Makefile b/Makefile index 9a12440..19ed698 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,9 @@ $(VENV) : lint : build $(VENV)/bin/ruff check src MYPYPATH=src $(VENV)/bin/mypy --namespace-packages --explicit-package-bases --install-types --non-interactive src - @# These options should be the same flags as in .pre-commit-config.yml + @# These options should be the same flags as in .pre-commit-config.yml, except that I can't get it to + @# work there without the "--ignore-missing-imports" flag, while it does work without it here + @# MYPYPATH is needed because apparently some type checking ignores the directory option given as command-line argument @# $(VENV)/bin/pylint src