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

Commit

Permalink
Fix subscriptable type usage in Python <3.9 (#15604)
Browse files Browse the repository at this point in the history
Fix the following `mypy` errors when running `mypy` with Python 3.7:
```
synapse/storage/controllers/stats.py:58: error: "Counter" is not subscriptable, use "typing.Counter" instead  [misc]

tests/test_state.py:267: error: "dict" is not subscriptable, use "typing.Dict" instead  [misc]
```

Part of #15603

In Python 3.9, `typing` is deprecated and the types are subscriptable (generics) by default, https://peps.python.org/pep-0585/#implementation
  • Loading branch information
MadLittleMods authored May 16, 2023
1 parent 0ccfb93 commit c51d2e6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/15604.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix subscriptable type usage in Python <3.9.
3 changes: 1 addition & 2 deletions synapse/storage/controllers/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# limitations under the License.

import logging
from collections import Counter
from typing import TYPE_CHECKING, Collection, List, Tuple
from typing import TYPE_CHECKING, Collection, Counter, List, Tuple

from synapse.api.errors import SynapseError
from synapse.storage.database import LoggingTransaction
Expand Down
2 changes: 1 addition & 1 deletion tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_branch_no_conflict(self) -> Generator[defer.Deferred, Any, None]:

self.dummy_store.register_events(graph.walk())

context_store: dict[str, EventContext] = {}
context_store: Dict[str, EventContext] = {}

for event in graph.walk():
context = yield defer.ensureDeferred(
Expand Down

0 comments on commit c51d2e6

Please sign in to comment.