Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Python 3.8 leftovers #17967

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/17967.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.8 EOL: compile native extensions with the 3.9 ABI and use typing hints from the standard library.
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pyo3 = { version = "0.21.0", features = [
"macros",
"anyhow",
"abi3",
"abi3-py38",
V02460 marked this conversation as resolved.
Show resolved Hide resolved
"abi3-py39",
] }
pyo3-log = "0.10.0"
pythonize = "0.21.0"
Expand Down
2 changes: 1 addition & 1 deletion synapse/_scripts/synapse_port_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
Set,
Tuple,
Type,
TypedDict,
TypeVar,
cast,
)

import yaml
from typing_extensions import TypedDict

from twisted.internet import defer, reactor as reactor_

Expand Down
4 changes: 1 addition & 3 deletions synapse/api/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
# [This file includes modifications made by New Vector Limited]
#
#
from typing import TYPE_CHECKING, Optional, Tuple

from typing_extensions import Protocol
from typing import TYPE_CHECKING, Optional, Protocol, Tuple

from twisted.web.server import Request

Expand Down
2 changes: 1 addition & 1 deletion synapse/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Mapping,
MutableMapping,
Optional,
Protocol,
Set,
Tuple,
Union,
Expand All @@ -41,7 +42,6 @@
from canonicaljson import encode_canonical_json
from signedjson.key import decode_verify_key_bytes
from signedjson.sign import SignatureVerifyException, verify_signed_json
from typing_extensions import Protocol
from unpaddedbase64 import decode_base64

from synapse.api.constants import (
Expand Down
2 changes: 1 addition & 1 deletion synapse/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Generic,
Iterable,
List,
Literal,
Optional,
Tuple,
Type,
Expand All @@ -39,7 +40,6 @@
)

import attr
from typing_extensions import Literal
from unpaddedbase64 import encode_base64

from synapse.api.constants import RelationTypes
Expand Down
2 changes: 1 addition & 1 deletion synapse/federation/sender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@
Hashable,
Iterable,
List,
Literal,
Optional,
Tuple,
)

import attr
from prometheus_client import Counter
from typing_extensions import Literal

from twisted.internet import defer

Expand Down
4 changes: 1 addition & 3 deletions synapse/federation/transport/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#
#
import logging
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple, Type

from typing_extensions import Literal
from typing import TYPE_CHECKING, Dict, Iterable, List, Literal, Optional, Tuple, Type

from synapse.api.errors import FederationDeniedError, SynapseError
from synapse.federation.transport.server._base import (
Expand Down
3 changes: 1 addition & 2 deletions synapse/federation/transport/server/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
TYPE_CHECKING,
Dict,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand All @@ -32,8 +33,6 @@
Union,
)

from typing_extensions import Literal

from synapse.api.constants import Direction, EduTypes
from synapse.api.errors import Codes, SynapseError
from synapse.api.room_versions import RoomVersions
Expand Down
4 changes: 1 addition & 3 deletions synapse/handlers/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

import logging
import string
from typing import TYPE_CHECKING, Iterable, List, Optional, Sequence

from typing_extensions import Literal
from typing import TYPE_CHECKING, Iterable, List, Literal, Optional, Sequence

from synapse.api.constants import MAX_ALIAS_LENGTH, EventTypes
from synapse.api.errors import (
Expand Down
4 changes: 1 addition & 3 deletions synapse/handlers/e2e_room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#

import logging
from typing import TYPE_CHECKING, Dict, Optional, cast

from typing_extensions import Literal
from typing import TYPE_CHECKING, Dict, Literal, Optional, cast

from synapse.api.errors import (
Codes,
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
List,
Optional,
Type,
TypedDict,
TypeVar,
Union,
)
Expand All @@ -52,7 +53,6 @@
MacaroonInitException,
MacaroonInvalidSignatureException,
)
from typing_extensions import TypedDict

from twisted.web.client import readBody
from twisted.web.http_headers import Headers
Expand Down
3 changes: 1 addition & 2 deletions synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
"""Contains functions for registering clients."""

import logging
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, TypedDict

from prometheus_client import Counter
from typing_extensions import TypedDict

from synapse import types
from synapse.api.constants import (
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
Mapping,
NoReturn,
Optional,
Protocol,
Set,
)
from urllib.parse import urlencode

import attr
from typing_extensions import Protocol

from twisted.web.iweb import IRequest
from twisted.web.server import Request
Expand Down
2 changes: 1 addition & 1 deletion synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
List,
Mapping,
Optional,
Protocol,
Tuple,
Union,
)
Expand All @@ -40,7 +41,6 @@
from canonicaljson import encode_canonical_json
from netaddr import AddrFormatError, IPAddress, IPSet
from prometheus_client import Counter
from typing_extensions import Protocol
from zope.interface import implementer, provider

from OpenSSL import SSL
Expand Down
2 changes: 1 addition & 1 deletion synapse/http/matrixfederationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Dict,
Generic,
List,
Literal,
Optional,
TextIO,
Tuple,
Expand All @@ -48,7 +49,6 @@
from canonicaljson import encode_canonical_json
from prometheus_client import Counter
from signedjson.sign import sign_json
from typing_extensions import Literal

from twisted.internet import defer
from twisted.internet.error import DNSLookupError
Expand Down
2 changes: 1 addition & 1 deletion synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
List,
Optional,
Pattern,
Protocol,
Tuple,
Union,
)

import attr
import jinja2
from canonicaljson import encode_canonical_json
from typing_extensions import Protocol
from zope.interface import implementer

from twisted.internet import defer, interfaces
Expand Down
3 changes: 1 addition & 2 deletions synapse/http/servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from typing import (
TYPE_CHECKING,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand All @@ -37,8 +38,6 @@
overload,
)

from typing_extensions import Literal

from twisted.web.server import Request

from synapse._pydantic_compat import (
Expand Down
3 changes: 2 additions & 1 deletion synapse/logging/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
Any,
Awaitable,
Callable,
Literal,
Optional,
Tuple,
Type,
Expand All @@ -49,7 +50,7 @@
)

import attr
from typing_extensions import Literal, ParamSpec
from typing_extensions import ParamSpec

from twisted.internet import defer, threads
from twisted.python.threadpool import ThreadPool
Expand Down
3 changes: 1 addition & 2 deletions synapse/logging/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#
#
import logging

from typing_extensions import Literal
from typing import Literal


class MetadataFilter(logging.Filter):
Expand Down
3 changes: 1 addition & 2 deletions synapse/metrics/jemalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
import logging
import os
import re
from typing import Iterable, Optional, overload
from typing import Iterable, Literal, Optional, overload

import attr
from prometheus_client import REGISTRY, Metric
from typing_extensions import Literal

from synapse.metrics import GaugeMetricFamily
from synapse.metrics._types import Collector
Expand Down
4 changes: 1 addition & 3 deletions synapse/module_api/callbacks/spamchecker_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
Callable,
Collection,
List,
Literal,
Optional,
Tuple,
Union,
)

# `Literal` appears with Python 3.8.
from typing_extensions import Literal

import synapse
from synapse.api.errors import Codes
from synapse.logging.opentracing import trace
Expand Down
4 changes: 1 addition & 3 deletions synapse/push/push_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
# [This file includes modifications made by New Vector Limited]
#
#
from typing import List, Optional

from typing_extensions import TypedDict
from typing import List, Optional, TypedDict


class EmailReason(TypedDict, total=False):
Expand Down
3 changes: 1 addition & 2 deletions synapse/rest/client/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
#
import logging
import random
from typing import TYPE_CHECKING, List, Optional, Tuple
from typing import TYPE_CHECKING, List, Literal, Optional, Tuple
from urllib.parse import urlparse

import attr
from typing_extensions import Literal

from twisted.web.server import Request

Expand Down
4 changes: 1 addition & 3 deletions synapse/rest/client/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#

import logging
from typing import TYPE_CHECKING, List, Optional, Tuple

from typing_extensions import Literal
from typing import TYPE_CHECKING, List, Literal, Optional, Tuple

from twisted.web.server import Request

Expand Down
3 changes: 1 addition & 2 deletions synapse/rest/client/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
List,
Optional,
Tuple,
TypedDict,
Union,
)

from typing_extensions import TypedDict

from synapse.api.constants import ApprovalNoticeMedium
from synapse.api.errors import (
Codes,
Expand Down
4 changes: 2 additions & 2 deletions synapse/state/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
Generator,
Iterable,
List,
Literal,
Optional,
Protocol,
Sequence,
Set,
Tuple,
overload,
)

from typing_extensions import Literal, Protocol

from synapse import event_auth
from synapse.api.constants import EventTypes
from synapse.api.errors import AuthError
Expand Down
3 changes: 2 additions & 1 deletion synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Iterable,
Iterator,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand All @@ -47,7 +48,7 @@

import attr
from prometheus_client import Counter, Histogram
from typing_extensions import Concatenate, Literal, ParamSpec
from typing_extensions import Concatenate, ParamSpec

from twisted.enterprise import adbapi
from twisted.internet.interfaces import IReactorCore
Expand Down
Loading
Loading