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

Commit

Permalink
Fix deprecation warning: import ABC from collections.abc (#7892)
Browse files Browse the repository at this point in the history
  • Loading branch information
tirkarthi authored Jul 20, 2020
1 parent 5ecf98f commit a7b06a8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/7892.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Import ABC from `collections.abc` for Python 3.10 compatibility.
6 changes: 3 additions & 3 deletions synapse/events/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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.
import collections
import collections.abc
import re
from typing import Any, Mapping, Union

Expand Down Expand Up @@ -424,7 +424,7 @@ def copy_power_levels_contents(
Raises:
TypeError if the input does not look like a valid power levels event content
"""
if not isinstance(old_power_levels, collections.Mapping):
if not isinstance(old_power_levels, collections.abc.Mapping):
raise TypeError("Not a valid power-levels content: %r" % (old_power_levels,))

power_levels = {}
Expand All @@ -434,7 +434,7 @@ def copy_power_levels_contents(
power_levels[k] = v
continue

if isinstance(v, collections.Mapping):
if isinstance(v, collections.abc.Mapping):
power_levels[k] = h = {}
for k1, v1 in v.items():
# we should only have one level of nesting
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import itertools
import logging
from collections import Container
from collections.abc import Container
from http import HTTPStatus
from typing import Dict, Iterable, List, Optional, Sequence, Tuple, Union

Expand Down
2 changes: 1 addition & 1 deletion synapse/replication/tcp/streams/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heapq
from collections import Iterable
from collections.abc import Iterable
from typing import List, Tuple, Type

import attr
Expand Down
2 changes: 1 addition & 1 deletion synapse/util/stringutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import random
import re
import string
from collections import Iterable
from collections.abc import Iterable

from synapse.api.errors import Codes, SynapseError

Expand Down

0 comments on commit a7b06a8

Please sign in to comment.