Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
_CacheContext: Restore compatibility with lower Python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai A. Hiller authored and Kai A. Hiller committed Nov 6, 2019
1 parent 30ac430 commit 94be60f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions synapse/util/caches/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations

import functools
import inspect
import logging
Expand Down Expand Up @@ -635,9 +633,8 @@ class _CacheContext:
on a lower level.
"""

_cache_context_objects: WeakValueDictionary[
Tuple[Cache, CacheKey], _CacheContext
] = WeakValueDictionary()
# WeakValueDictionary is not a generic at runtime, so we need the quotes (Py <3.7)
_cache_context_objects: "WeakValueDictionary[Tuple[Cache, CacheKey], _CacheContext]" = WeakValueDictionary()

def __init__(self, cache: Cache, cache_key: CacheKey) -> None:
self._cache = cache
Expand All @@ -648,7 +645,7 @@ def invalidate(self) -> None:
self._cache.invalidate(self._cache_key)

@classmethod
def get_instance(cls, cache: Cache, cache_key: CacheKey) -> _CacheContext:
def get_instance(cls, cache: Cache, cache_key: CacheKey) -> "_CacheContext":
"""Returns an instance constructed with the given arguments.
A new instance is only created if none already exists.
Expand Down

0 comments on commit 94be60f

Please sign in to comment.