diff options
author | David Robertson <davidr@element.io> | 2021-10-07 12:05:04 +0100 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2021-10-07 12:05:04 +0100 |
commit | 4d0bc243ed0f3f3bf7f973f05a6826f56bcc8284 (patch) | |
tree | 7a64a25f62a517542b0389649715088b4eb2955d | |
parent | Workaround https://github.com/python/mypy/issues/6463 (diff) | |
download | synapse-4d0bc243ed0f3f3bf7f973f05a6826f56bcc8284.tar.xz |
Other mypy fixes
-rw-r--r-- | synapse/storage/prepare_database.py | 1 | ||||
-rw-r--r-- | synapse/util/__init__.py | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/synapse/storage/prepare_database.py b/synapse/storage/prepare_database.py index a63eaddfdc..5963e985ab 100644 --- a/synapse/storage/prepare_database.py +++ b/synapse/storage/prepare_database.py @@ -487,6 +487,7 @@ def _upgrade_existing_database( spec = importlib.util.spec_from_file_location( module_name, absolute_path ) + assert spec is not None module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) # type: ignore diff --git a/synapse/util/__init__.py b/synapse/util/__init__.py index 64daff59df..abf53d149d 100644 --- a/synapse/util/__init__.py +++ b/synapse/util/__init__.py @@ -51,7 +51,10 @@ def _handle_frozendict(obj: Any) -> Dict[Any, Any]: # fishing the protected dict out of the object is a bit nasty, # but we don't really want the overhead of copying the dict. try: - return obj._dict + # Safety: we catch the AttributeError immediately below. + # See https://github.com/matrix-org/python-canonicaljson/issues/36#issuecomment-927816293 + # for discussion on how frozendict's internals have changed over time. + return obj._dict # type: ignore[attr-defined] except AttributeError: # When the C implementation of frozendict is used, # there isn't a `_dict` attribute with a dict |