From 20a7e94fc3e3958e9ea9ae0d14894e4ea21e6e26 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 15 Feb 2023 17:50:41 +0000 Subject: [PATCH] Use a property to define `Jsonlibrary` This is suggested/recommended at https://github.com/python/mypy/issues/6002 Discovered as part of https://github.com/matrix-org/synapse/pull/15052 --- src/canonicaljson/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/canonicaljson/__init__.py b/src/canonicaljson/__init__.py index d481262..8337de1 100644 --- a/src/canonicaljson/__init__.py +++ b/src/canonicaljson/__init__.py @@ -52,7 +52,9 @@ def __call__(self, *args: Any, **kwargs: Any) -> "Encoder": class JsonLibrary(Protocol): - JSONEncoder: Encoder + @property + def JSONEncoder(self) -> Encoder: + pass # Declare these in the module scope, but they get configured in