From 7862f821de30b17ed035a3355e552d027429dc6b Mon Sep 17 00:00:00 2001 From: Sean Quah <8349537+squahtx@users.noreply.github.com> Date: Thu, 25 Nov 2021 16:14:23 +0000 Subject: Annotate string constants in `synapse.api.constants` with `Final` (#11356) This change makes mypy complain if the constants are ever reassigned, and, more usefully, makes mypy type them as `Literal`s instead of `str`s, allowing code of the following form to pass mypy: ```py def do_something(membership: Literal["join", "leave"], ...): ... do_something(Membership.JOIN, ...) ``` --- changelog.d/11356.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/11356.misc (limited to 'changelog.d/11356.misc') diff --git a/changelog.d/11356.misc b/changelog.d/11356.misc new file mode 100644 index 0000000000..01ce6a306c --- /dev/null +++ b/changelog.d/11356.misc @@ -0,0 +1 @@ +Add `Final` annotation to string constants in `synapse.api.constants` so that they get typed as `Literal`s. -- cgit 1.4.1