Skip to content

Commit

Permalink
Revert "Cleanup Python 3.8 leftovers (#17967)"
Browse files Browse the repository at this point in the history
This reverts commit 068e22b.

Reverted commit breaks Synapse on Red Hat Enterprise Linux 9
(Alma Linux 9, Rocky Linux 9. Oracle Linux 9).
Multiple tests fail with TypeError deep inside Pydantic because
issubclass(Literal, Tuple) complains that Literal is not a class.

Reverting the commit mentioned above fixes the issue.

Signed-off-by: Oleg Girko <[email protected]>
  • Loading branch information
OlegGirko committed Feb 27, 2025
1 parent c360da0 commit 758426c
Show file tree
Hide file tree
Showing 54 changed files with 94 additions and 103 deletions.
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.23.2", features = [
"macros",
"anyhow",
"abi3",
"abi3-py39",
"abi3-py38",
] }
pyo3-log = "0.12.0"
pythonize = "0.23.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: 3 additions & 1 deletion synapse/api/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
# [This file includes modifications made by New Vector Limited]
#
#
from typing import TYPE_CHECKING, Optional, Protocol, Tuple
from typing import TYPE_CHECKING, Optional, Tuple

from typing_extensions import Protocol

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,7 +32,6 @@
Mapping,
MutableMapping,
Optional,
Protocol,
Set,
Tuple,
Union,
Expand All @@ -42,6 +41,7 @@
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,7 +30,6 @@
Generic,
Iterable,
List,
Literal,
Optional,
Tuple,
Type,
Expand All @@ -40,6 +39,7 @@
)

import attr
from typing_extensions import Literal
from unpaddedbase64 import encode_base64

from synapse.api.constants import EventTypes, 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: 3 additions & 1 deletion synapse/federation/transport/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#
#
import logging
from typing import TYPE_CHECKING, Dict, Iterable, List, Literal, Optional, Tuple, Type
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple, Type

from typing_extensions import Literal

from synapse.api.errors import FederationDeniedError, SynapseError
from synapse.federation.transport.server._base import (
Expand Down
3 changes: 2 additions & 1 deletion synapse/federation/transport/server/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
TYPE_CHECKING,
Dict,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand All @@ -33,6 +32,8 @@
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: 3 additions & 1 deletion synapse/handlers/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

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

from typing_extensions import Literal

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

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

from typing_extensions import Literal

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,7 +31,6 @@
List,
Optional,
Type,
TypedDict,
TypeVar,
Union,
)
Expand All @@ -53,6 +52,7 @@
MacaroonInitException,
MacaroonInvalidSignatureException,
)
from typing_extensions import TypedDict

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

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

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,7 +31,6 @@
List,
Mapping,
Optional,
Protocol,
Tuple,
Union,
)
Expand All @@ -41,6 +40,7 @@
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

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,7 +34,6 @@
Dict,
Generic,
List,
Literal,
Optional,
TextIO,
Tuple,
Expand All @@ -49,6 +48,7 @@
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: 2 additions & 1 deletion synapse/http/servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from typing import (
TYPE_CHECKING,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand All @@ -38,6 +37,8 @@
overload,
)

from typing_extensions import Literal

from twisted.web.server import Request

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

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

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

from typing_extensions import Literal


class MetadataFilter(logging.Filter):
Expand Down
3 changes: 2 additions & 1 deletion synapse/metrics/jemalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import logging
import os
import re
from typing import Iterable, Literal, Optional, overload
from typing import Iterable, 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: 3 additions & 1 deletion synapse/module_api/callbacks/spamchecker_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
Callable,
Collection,
List,
Literal,
Optional,
Tuple,
Union,
cast,
)

# `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: 3 additions & 1 deletion synapse/push/push_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
# [This file includes modifications made by New Vector Limited]
#
#
from typing import List, Optional, TypedDict
from typing import List, Optional

from typing_extensions import TypedDict


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

import attr
from typing_extensions import Literal

from twisted.web.server import Request

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

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

from typing_extensions import Literal

from twisted.web.server import Request

Expand Down
3 changes: 2 additions & 1 deletion synapse/rest/client/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
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: 1 addition & 2 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
Iterable,
Iterator,
List,
Literal,
Mapping,
Optional,
Sequence,
Expand All @@ -48,7 +47,7 @@

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

from twisted.enterprise import adbapi
from twisted.internet.interfaces import IReactorCore
Expand Down
13 changes: 2 additions & 11 deletions synapse/storage/databases/main/client_ips.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,10 @@
#

import logging
from typing import (
TYPE_CHECKING,
Dict,
List,
Mapping,
Optional,
Tuple,
TypedDict,
Union,
cast,
)
from typing import TYPE_CHECKING, Dict, List, Mapping, Optional, Tuple, Union, cast

import attr
from typing_extensions import TypedDict

from synapse.metrics.background_process_metrics import wrap_as_background_process
from synapse.storage._base import SQLBaseStore
Expand Down
Loading

0 comments on commit 758426c

Please sign in to comment.