Skip to content

Commit

Permalink
Bump black from 23.10.1 to 24.2.0 (#16936)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] committed Mar 13, 2024
1 parent 2bdf628 commit 1e68b56
Show file tree
Hide file tree
Showing 74 changed files with 407 additions and 509 deletions.
44 changes: 24 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions synapse/_scripts/synapse_port_db.py
Expand Up @@ -1040,10 +1040,10 @@ async def _get_total_count_to_port(
return done, remaining + done

async def _setup_state_group_id_seq(self) -> None:
curr_id: Optional[
int
] = await self.sqlite_store.db_pool.simple_select_one_onecol(
table="state_groups", keyvalues={}, retcol="MAX(id)", allow_none=True
curr_id: Optional[int] = (
await self.sqlite_store.db_pool.simple_select_one_onecol(
table="state_groups", keyvalues={}, retcol="MAX(id)", allow_none=True
)
)

if not curr_id:
Expand Down Expand Up @@ -1132,13 +1132,13 @@ def r(txn: LoggingTransaction) -> None:
)

async def _setup_auth_chain_sequence(self) -> None:
curr_chain_id: Optional[
int
] = await self.sqlite_store.db_pool.simple_select_one_onecol(
table="event_auth_chains",
keyvalues={},
retcol="MAX(chain_id)",
allow_none=True,
curr_chain_id: Optional[int] = (
await self.sqlite_store.db_pool.simple_select_one_onecol(
table="event_auth_chains",
keyvalues={},
retcol="MAX(chain_id)",
allow_none=True,
)
)

def r(txn: LoggingTransaction) -> None:
Expand Down
1 change: 0 additions & 1 deletion synapse/api/constants.py
Expand Up @@ -43,7 +43,6 @@


class Membership:

"""Represents the membership states of a user in a room."""

INVITE: Final = "invite"
Expand Down
8 changes: 5 additions & 3 deletions synapse/api/room_versions.py
Expand Up @@ -370,9 +370,11 @@ class RoomVersionCapability:

MSC3244_CAPABILITIES = {
cap.identifier: {
"preferred": cap.preferred_version.identifier
if cap.preferred_version is not None
else None,
"preferred": (
cap.preferred_version.identifier
if cap.preferred_version is not None
else None
),
"support": [
v.identifier
for v in KNOWN_ROOM_VERSIONS.values()
Expand Down
6 changes: 3 additions & 3 deletions synapse/app/homeserver.py
Expand Up @@ -188,9 +188,9 @@ def _configure_named_resource(
PasswordResetSubmitTokenResource,
)

resources[
"/_synapse/client/password_reset/email/submit_token"
] = PasswordResetSubmitTokenResource(self)
resources["/_synapse/client/password_reset/email/submit_token"] = (
PasswordResetSubmitTokenResource(self)
)

if name == "consent":
from synapse.rest.consent.consent_resource import ConsentResource
Expand Down
18 changes: 9 additions & 9 deletions synapse/appservice/api.py
Expand Up @@ -362,16 +362,16 @@ async def push_bulk(
# TODO: Update to stable prefixes once MSC3202 completes FCP merge
if service.msc3202_transaction_extensions:
if one_time_keys_count:
body[
"org.matrix.msc3202.device_one_time_key_counts"
] = one_time_keys_count
body[
"org.matrix.msc3202.device_one_time_keys_count"
] = one_time_keys_count
body["org.matrix.msc3202.device_one_time_key_counts"] = (
one_time_keys_count
)
body["org.matrix.msc3202.device_one_time_keys_count"] = (
one_time_keys_count
)
if unused_fallback_keys:
body[
"org.matrix.msc3202.device_unused_fallback_key_types"
] = unused_fallback_keys
body["org.matrix.msc3202.device_unused_fallback_key_types"] = (
unused_fallback_keys
)
if device_list_summary:
body["org.matrix.msc3202.device_lists"] = {
"changed": list(device_list_summary.changed),
Expand Down
6 changes: 3 additions & 3 deletions synapse/config/registration.py
Expand Up @@ -171,9 +171,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
refreshable_access_token_lifetime = self.parse_duration(
refreshable_access_token_lifetime
)
self.refreshable_access_token_lifetime: Optional[
int
] = refreshable_access_token_lifetime
self.refreshable_access_token_lifetime: Optional[int] = (
refreshable_access_token_lifetime
)

if (
self.session_lifetime is not None
Expand Down
6 changes: 3 additions & 3 deletions synapse/config/repository.py
Expand Up @@ -199,9 +199,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
provider_config["module"] == "file_system"
or provider_config["module"] == "synapse.rest.media.v1.storage_provider"
):
provider_config[
"module"
] = "synapse.media.storage_provider.FileStorageProviderBackend"
provider_config["module"] = (
"synapse.media.storage_provider.FileStorageProviderBackend"
)

provider_class, parsed_config = load_module(
provider_config, ("media_storage_providers", "<item %i>" % i)
Expand Down
3 changes: 1 addition & 2 deletions synapse/event_auth.py
Expand Up @@ -88,8 +88,7 @@ async def get_events(
redact_behaviour: EventRedactBehaviour,
get_prev_content: bool = False,
allow_rejected: bool = False,
) -> Dict[str, "EventBase"]:
...
) -> Dict[str, "EventBase"]: ...


def validate_event_for_room_version(event: "EventBase") -> None:
Expand Down
12 changes: 4 additions & 8 deletions synapse/events/__init__.py
Expand Up @@ -93,16 +93,14 @@ def __get__(
self,
instance: Literal[None],
owner: Optional[Type[_DictPropertyInstance]] = None,
) -> "DictProperty":
...
) -> "DictProperty": ...

@overload
def __get__(
self,
instance: _DictPropertyInstance,
owner: Optional[Type[_DictPropertyInstance]] = None,
) -> T:
...
) -> T: ...

def __get__(
self,
Expand Down Expand Up @@ -161,16 +159,14 @@ def __get__(
self,
instance: Literal[None],
owner: Optional[Type[_DictPropertyInstance]] = None,
) -> "DefaultDictProperty":
...
) -> "DefaultDictProperty": ...

@overload
def __get__(
self,
instance: _DictPropertyInstance,
owner: Optional[Type[_DictPropertyInstance]] = None,
) -> T:
...
) -> T: ...

def __get__(
self,
Expand Down
6 changes: 3 additions & 3 deletions synapse/events/utils.py
Expand Up @@ -612,9 +612,9 @@ async def _inject_bundled_aggregations(
serialized_aggregations = {}

if event_aggregations.references:
serialized_aggregations[
RelationTypes.REFERENCE
] = event_aggregations.references
serialized_aggregations[RelationTypes.REFERENCE] = (
event_aggregations.references
)

if event_aggregations.replace:
# Include information about it in the relations dict.
Expand Down
6 changes: 3 additions & 3 deletions synapse/federation/federation_server.py
Expand Up @@ -169,9 +169,9 @@ def __init__(self, hs: "HomeServer"):

# We cache responses to state queries, as they take a while and often
# come in waves.
self._state_resp_cache: ResponseCache[
Tuple[str, Optional[str]]
] = ResponseCache(hs.get_clock(), "state_resp", timeout_ms=30000)
self._state_resp_cache: ResponseCache[Tuple[str, Optional[str]]] = (
ResponseCache(hs.get_clock(), "state_resp", timeout_ms=30000)
)
self._state_ids_resp_cache: ResponseCache[Tuple[str, str]] = ResponseCache(
hs.get_clock(), "state_ids_resp", timeout_ms=30000
)
Expand Down
6 changes: 3 additions & 3 deletions synapse/federation/send_queue.py
Expand Up @@ -88,9 +88,9 @@ def __init__(self, hs: "HomeServer"):
# Stores the destinations we need to explicitly send presence to about a
# given user.
# Stream position -> (user_id, destinations)
self.presence_destinations: SortedDict[
int, Tuple[str, Iterable[str]]
] = SortedDict()
self.presence_destinations: SortedDict[int, Tuple[str, Iterable[str]]] = (
SortedDict()
)

# (destination, key) -> EDU
self.keyed_edu: Dict[Tuple[str, tuple], Edu] = {}
Expand Down
8 changes: 4 additions & 4 deletions synapse/handlers/account.py
Expand Up @@ -118,10 +118,10 @@ async def _get_local_account_status(self, user_id: UserID) -> JsonDict:
}

if self._use_account_validity_in_account_status:
status[
"org.matrix.expired"
] = await self._account_validity_handler.is_user_expired(
user_id.to_string()
status["org.matrix.expired"] = (
await self._account_validity_handler.is_user_expired(
user_id.to_string()
)
)

return status
Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/directory.py
Expand Up @@ -265,9 +265,9 @@ async def _delete_association(self, room_alias: RoomAlias) -> Optional[str]:
async def get_association(self, room_alias: RoomAlias) -> JsonDict:
room_id = None
if self.hs.is_mine(room_alias):
result: Optional[
RoomAliasMapping
] = await self.get_association_from_room_alias(room_alias)
result: Optional[RoomAliasMapping] = (
await self.get_association_from_room_alias(room_alias)
)

if result:
room_id = result.room_id
Expand Down
10 changes: 5 additions & 5 deletions synapse/handlers/federation.py
Expand Up @@ -1001,11 +1001,11 @@ async def on_make_join_request(
)

if include_auth_user_id:
event_content[
EventContentFields.AUTHORISING_USER
] = await self._event_auth_handler.get_user_which_could_invite(
room_id,
state_ids,
event_content[EventContentFields.AUTHORISING_USER] = (
await self._event_auth_handler.get_user_which_could_invite(
room_id,
state_ids,
)
)

builder = self.event_builder_factory.for_room_version(
Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/federation_event.py
Expand Up @@ -1367,9 +1367,9 @@ async def _get_state_ids_after_missing_prev_event(
)

if remote_event.is_state() and remote_event.rejected_reason is None:
state_map[
(remote_event.type, remote_event.state_key)
] = remote_event.event_id
state_map[(remote_event.type, remote_event.state_key)] = (
remote_event.event_id
)

return state_map

Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/message.py
Expand Up @@ -1654,9 +1654,9 @@ async def cache_joined_hosts_for_events(
expiry_ms=60 * 60 * 1000,
)

self._external_cache_joined_hosts_updates[
state_entry.state_group
] = None
self._external_cache_joined_hosts_updates[state_entry.state_group] = (
None
)

async def _validate_canonical_alias(
self,
Expand Down
12 changes: 6 additions & 6 deletions synapse/handlers/presence.py
Expand Up @@ -493,9 +493,9 @@ def __init__(self, hs: "HomeServer"):

# The number of ongoing syncs on this process, by (user ID, device ID).
# Empty if _presence_enabled is false.
self._user_device_to_num_current_syncs: Dict[
Tuple[str, Optional[str]], int
] = {}
self._user_device_to_num_current_syncs: Dict[Tuple[str, Optional[str]], int] = (
{}
)

self.notifier = hs.get_notifier()
self.instance_id = hs.get_instance_id()
Expand Down Expand Up @@ -818,9 +818,9 @@ def __init__(self, hs: "HomeServer"):

# Keeps track of the number of *ongoing* syncs on this process. While
# this is non zero a user will never go offline.
self._user_device_to_num_current_syncs: Dict[
Tuple[str, Optional[str]], int
] = {}
self._user_device_to_num_current_syncs: Dict[Tuple[str, Optional[str]], int] = (
{}
)

# Keeps track of the number of *ongoing* syncs on other processes.
#
Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/profile.py
Expand Up @@ -320,9 +320,9 @@ async def check_avatar_size_and_mime_type(self, mxc: str) -> bool:
server_name = host

if self._is_mine_server_name(server_name):
media_info: Optional[
Union[LocalMedia, RemoteMedia]
] = await self.store.get_local_media(media_id)
media_info: Optional[Union[LocalMedia, RemoteMedia]] = (
await self.store.get_local_media(media_id)
)
else:
media_info = await self.store.get_cached_remote_media(server_name, media_id)

Expand Down

0 comments on commit 1e68b56

Please sign in to comment.