From 7fecb9fed7f06f36725d900274f023426e795c58 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Sun, 29 May 2022 22:02:44 +0100 Subject: [PATCH 1/3] Bump jsonschema stubs Fixes #12901 by incoprating https://github.com/python/typeshed/pull/7980 (The olddeps will automatically be fixed now, but let's pull in the more complete stubs for day-to-day use while we're at it.) --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index f64d70941e77..6b4686545be6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1355,7 +1355,7 @@ python-versions = "*" [[package]] name = "types-jsonschema" -version = "4.4.1" +version = "4.4.6" description = "Typing stubs for jsonschema" category = "dev" optional = false @@ -2618,8 +2618,8 @@ types-ipaddress = [ {file = "types_ipaddress-1.0.8-py3-none-any.whl", hash = "sha256:4933b74da157ba877b1a705d64f6fa7742745e9ffd65e51011f370c11ebedb55"}, ] types-jsonschema = [ - {file = "types-jsonschema-4.4.1.tar.gz", hash = "sha256:bd68b75217ebbb33b0242db10047581dad3b061a963a46ee80d4a9044080663e"}, - {file = "types_jsonschema-4.4.1-py3-none-any.whl", hash = "sha256:ab3ecfdc912d6091cc82f4b7556cfbf1a7cbabc26da0ceaa1cbbc232d1d09971"}, + {file = "types-jsonschema-4.4.6.tar.gz", hash = "sha256:7f2a804618756768c7c0616f8c794b61fcfe3077c7ee1ad47dcf01c5e5f692bb"}, + {file = "types_jsonschema-4.4.6-py3-none-any.whl", hash = "sha256:1db9031ca49a8444d01bd2ce8cf2f89318382b04610953b108321e6f8fb03390"}, ] types-opentracing = [ {file = "types-opentracing-2.4.7.tar.gz", hash = "sha256:be60e9618355aa892571ace002e6b353702538b1c0dc4fbc1c921219d6658830"}, From 5324ad0bfb0ccfa7a77393c88264994fedeb189b Mon Sep 17 00:00:00 2001 From: David Robertson Date: Sun, 29 May 2022 22:07:43 +0100 Subject: [PATCH 2/3] Changelog --- changelog.d/12912.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12912.misc diff --git a/changelog.d/12912.misc b/changelog.d/12912.misc new file mode 100644 index 000000000000..6396fd9d3675 --- /dev/null +++ b/changelog.d/12912.misc @@ -0,0 +1 @@ +Bump types-jsonschema from 4.4.1 to 4.4.6. From e97a34e7a5a5217da37604c7d6d9e7401b652627 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Sun, 29 May 2022 22:21:23 +0100 Subject: [PATCH 3/3] Fix mypy? --- synapse/events/validator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/synapse/events/validator.py b/synapse/events/validator.py index 360d24274a52..29fa9b388026 100644 --- a/synapse/events/validator.py +++ b/synapse/events/validator.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import collections.abc -from typing import Iterable, Type, Union +from typing import Iterable, Type, Union, cast import jsonschema @@ -103,7 +103,12 @@ def validate_new(self, event: EventBase, config: HomeServerConfig) -> None: except jsonschema.ValidationError as e: if e.path: # example: "users_default": '0' is not of type 'integer' - message = '"' + e.path[-1] + '": ' + e.message # noqa: B306 + # cast safety: path entries can be integers, if we fail to validate + # items in an array. However the POWER_LEVELS_SCHEMA doesn't expect + # to see any arrays. + message = ( + '"' + cast(str, e.path[-1]) + '": ' + e.message # noqa: B306 + ) # jsonschema.ValidationError.message is a valid attribute else: # example: '0' is not of type 'integer'