Skip to content

Commit 78ce4dc

Browse files
Bump mypy from 1.13.0 to 1.16.1 (#18653)
1 parent 97d2738 commit 78ce4dc

File tree

19 files changed

+112
-69
lines changed

19 files changed

+112
-69
lines changed

changelog.d/18653.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix typing errors with upgraded mypy version.

poetry.lock

Lines changed: 52 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

synapse/config/cas.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
4242
self.cas_enabled = cas_config and cas_config.get("enabled", True)
4343

4444
if self.cas_enabled:
45+
if not isinstance(cas_config, dict):
46+
raise ConfigError("Must be a dictionary", ("cas_config",))
47+
4548
self.cas_server_url = cas_config["server_url"]
4649

4750
# TODO Update this to a _synapse URL.

synapse/config/key.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ def read_config(
212212
"Config options that expect an in-line secret as value are disabled",
213213
("form_secret",),
214214
)
215+
if form_secret is not None and not isinstance(form_secret, str):
216+
raise ConfigError("Config option must be a string", ("form_secret",))
217+
215218
form_secret_path = config.get("form_secret_path", None)
216219
if form_secret_path:
217220
if form_secret:
218221
raise ConfigError(CONFLICTING_FORM_SECRET_OPTS_ERROR)
219-
self.form_secret = read_file(
222+
self.form_secret: Optional[str] = read_file(
220223
form_secret_path, ("form_secret_path",)
221224
).strip()
222225
else:

synapse/config/workers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,16 @@ def read_config(
238238
if worker_replication_secret_path:
239239
if worker_replication_secret:
240240
raise ConfigError(CONFLICTING_WORKER_REPLICATION_SECRET_OPTS_ERROR)
241-
self.worker_replication_secret = read_file(
241+
self.worker_replication_secret: Optional[str] = read_file(
242242
worker_replication_secret_path, ("worker_replication_secret_path",)
243243
).strip()
244244
else:
245+
if worker_replication_secret is not None and not isinstance(
246+
worker_replication_secret, str
247+
):
248+
raise ConfigError(
249+
"Config option must be a string", ("worker_replication_secret",)
250+
)
245251
self.worker_replication_secret = worker_replication_secret
246252

247253
self.worker_name = config.get("worker_name", self.worker_app)

synapse/handlers/auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def login_id_phone_to_thirdparty(identifier: JsonDict) -> Dict[str, str]:
174174

175175
# Accept both "phone" and "number" as valid keys in m.id.phone
176176
phone_number = identifier.get("phone", identifier["number"])
177+
assert isinstance(phone_number, str)
177178

178179
# Convert user-provided phone number to a consistent representation
179180
msisdn = phone_number_to_msisdn(identifier["country"], phone_number)

synapse/handlers/cas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ async def cas_response_to_user_attributes(failures: int) -> UserAttributes:
378378

379379
# Arbitrarily use the first attribute found.
380380
display_name = cas_response.attributes.get(
381-
self._cas_displayname_attribute, [None]
381+
self._cas_displayname_attribute, # type: ignore[arg-type]
382+
[None],
382383
)[0]
383384

384385
return UserAttributes(localpart=localpart, display_name=display_name)

synapse/handlers/presence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ async def set_state(
14051405
# Based on the state of each user's device calculate the new presence state.
14061406
presence = _combine_device_states(devices.values())
14071407

1408-
new_fields = {"state": presence}
1408+
new_fields: JsonDict = {"state": presence}
14091409

14101410
if presence == PresenceState.ONLINE or presence == PresenceState.BUSY:
14111411
new_fields["last_active_ts"] = now

synapse/handlers/register.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ async def _join_rooms(self, user_id: str) -> None:
557557
if join_rules_event:
558558
join_rule = join_rules_event.content.get("join_rule", None)
559559
requires_invite = (
560-
join_rule and join_rule != JoinRules.PUBLIC
560+
join_rule is not None and join_rule != JoinRules.PUBLIC
561561
)
562562

563563
# Send the invite, if necessary.

synapse/handlers/send_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async def send_email(
197197
additional_headers: A map of additional headers to include.
198198
"""
199199
try:
200-
from_string = self._from % {"app": app_name}
200+
from_string = self._from % {"app": app_name} # type: ignore[operator]
201201
except (KeyError, TypeError):
202202
from_string = self._from
203203

0 commit comments

Comments
 (0)