From 400d0d9d0a0d6a8e0b04c4c487a8901afcd4688b Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 12 Oct 2021 13:55:56 +0100 Subject: [PATCH 1/4] Properly mark Module API error imports as re-exported F401 no longer fails if you do this, either. --- synapse/module_api/errors.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/synapse/module_api/errors.py b/synapse/module_api/errors.py index 98ea911a8195..1db900e41f64 100644 --- a/synapse/module_api/errors.py +++ b/synapse/module_api/errors.py @@ -14,9 +14,16 @@ """Exception types which are exposed as part of the stable module API""" -from synapse.api.errors import ( # noqa: F401 +from synapse.api.errors import ( InvalidClientCredentialsError, RedirectException, SynapseError, ) -from synapse.config._base import ConfigError # noqa: F401 +from synapse.config._base import ConfigError + +__all__ = [ + "InvalidClientCredentialsError", + "RedirectException", + "SynapseError", + "ConfigError", +] From 42cccbbac26f07124644d58b44791a00de3938ab Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 12 Oct 2021 13:56:41 +0100 Subject: [PATCH 2/4] Add py.typed file to mark this package as containing type annotations Mypy won't look for annotations without this file --- synapse/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 synapse/py.typed diff --git a/synapse/py.typed b/synapse/py.typed new file mode 100644 index 000000000000..e69de29bb2d1 From f0837cf996b50312c1be18b2d069744be1e9dd96 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 12 Oct 2021 13:58:04 +0100 Subject: [PATCH 3/4] Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/11054.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/11054.misc diff --git a/changelog.d/11054.misc b/changelog.d/11054.misc new file mode 100644 index 000000000000..1103368fecfe --- /dev/null +++ b/changelog.d/11054.misc @@ -0,0 +1 @@ +Mark the Synapse package as containing type annotations and fix export declarations so that Synapse pluggable modules may be type checked against Synapse. From f3286984a811c484389f03af068623f151d7ca19 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 12 Oct 2021 14:16:59 +0100 Subject: [PATCH 4/4] Include synapse/py.typed in the MANIFEST --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 44d5cc761816..c24786c3b371 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,6 +8,7 @@ include demo/demo.tls.dh include demo/*.py include demo/*.sh +include synapse/py.typed recursive-include synapse/storage *.sql recursive-include synapse/storage *.sql.postgres recursive-include synapse/storage *.sql.sqlite