From 8fd3e1493556a9c487a89d2ebd4c2bc7af2d0b0c Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 20 May 2022 11:46:44 -0400 Subject: [PATCH] fixed typeguard usage w/ burnettk --- .github/workflows/tests.yml | 5 ++++- conftest.py | 10 +++++++++- noxfile.py | 3 ++- src/spiff_workflow_webapp/db.sqlite3 | Bin 36864 -> 0 bytes 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a66e0da1..57200fb0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,7 +61,10 @@ jobs: database: "sqlite", } - { - python: "3.10", + # typeguard 2.13.3 is broken with TypeDict in 3.10. + # probably the next release fixes it. + # https://github.com/agronholm/typeguard/issues/242 + python: "3.9", os: "ubuntu-latest", session: "typeguard", database: "sqlite", diff --git a/conftest.py b/conftest.py index a263885c..f345fb58 100644 --- a/conftest.py +++ b/conftest.py @@ -3,8 +3,16 @@ import os import pytest from flask.app import Flask +from typeguard.importhook import install_import_hook -from spiff_workflow_webapp import create_app + +# We need to call this before importing spiff_workflow_webapp +# otherwise typeguard cannot work. hence the noqa: E402 +if os.environ.get("RUN_TYPEGUARD") == "true": + install_import_hook(packages="spiff_workflow_webapp") + + +from spiff_workflow_webapp import create_app # noqa: E402 @pytest.fixture(scope="session") diff --git a/noxfile.py b/noxfile.py index beb878ec..416d959b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -156,7 +156,8 @@ def typeguard(session: Session) -> None: """Runtime type checking using Typeguard.""" session.install(".") session.install("pytest", "typeguard", "pygments") - session.run("pytest", f"--typeguard-packages={package}", *session.posargs) + session.env["RUN_TYPEGUARD"] = "true" + session.run("pytest", *session.posargs) @session(python=python_versions) diff --git a/src/spiff_workflow_webapp/db.sqlite3 b/src/spiff_workflow_webapp/db.sqlite3 index d282a2c6404a4e089f32c4a8575fdfa0c5ff7979..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 36864 zcmeI(U2oD*7{Kv%FT72LH%l))S+WeW#W*&Gi7|?#n@j{(m}VEI;iX%uP#6X0r7V6a zzsEj^m)@Azc7PON-ow9HxAwgCJiq6J0nm43i^hJee~bQ(K8oJ1Sr2Y!b)p;r1Q0*~ z0R#|00D<`sxTyt$N;)lnH@cN-!|2&YN5AZ}dTqU8+vcU!G_3B_!cbOIGi6njGq3Wh znA$|dBVn^Ha)q*btZJfAEQ`WfKEEp>VXys+y1U2EsC=j8-e$CO@kTutakHLq2RkZi zYVNq;mc@si6GBsuR81{p)soosN;ju=7|g`i-Ypw7&K3)$vX*h8m>#9xv&^fWAN(HK=TC z$T!EMgt-j^|D@wT`c|cBi1!&S`#Ph=Q%@4U^h{Q|%0{zdHpY9nh11e84&e@zh$OZH z0p;1oz43eD2K&-VP}$y=`!Brc+MQO-ux-8Bsv8a8&8jb6U)4QfB*srAb