Skip to content

Commit a775184

Browse files
Chore: Add assertions to fix mypy errors for trino and errors for latest duckdb (#5724)
1 parent 6e69ce6 commit a775184

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

sqlmesh/core/config/connection.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,17 @@ def _static_connection_kwargs(self) -> t.Dict[str, t.Any]:
20132013
OAuth2Authentication,
20142014
)
20152015

2016+
auth: t.Optional[
2017+
t.Union[
2018+
BasicAuthentication,
2019+
KerberosAuthentication,
2020+
OAuth2Authentication,
2021+
JWTAuthentication,
2022+
CertificateAuthentication,
2023+
]
2024+
] = None
20162025
if self.method.is_basic or self.method.is_ldap:
2026+
assert self.password is not None # for mypy since validator already checks this
20172027
auth = BasicAuthentication(self.user, self.password)
20182028
elif self.method.is_kerberos:
20192029
if self.keytab:
@@ -2032,11 +2042,12 @@ def _static_connection_kwargs(self) -> t.Dict[str, t.Any]:
20322042
elif self.method.is_oauth:
20332043
auth = OAuth2Authentication()
20342044
elif self.method.is_jwt:
2045+
assert self.jwt_token is not None
20352046
auth = JWTAuthentication(self.jwt_token)
20362047
elif self.method.is_certificate:
2048+
assert self.client_certificate is not None
2049+
assert self.client_private_key is not None
20372050
auth = CertificateAuthentication(self.client_certificate, self.client_private_key)
2038-
else:
2039-
auth = None
20402051

20412052
return {
20422053
"auth": auth,

tests/core/integration/test_aux_commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,20 @@ def test_destroy(copy_to_temp_path):
287287

288288
# Validate tables have been deleted as well
289289
with pytest.raises(
290-
Exception, match=r"Catalog Error: Table with name model_two does not exist!"
290+
Exception, match=r"Catalog Error: Table with name.*model_two.*does not exist"
291291
):
292292
context.fetchdf("SELECT * FROM db_1.first_schema.model_two")
293293
with pytest.raises(
294-
Exception, match=r"Catalog Error: Table with name model_one does not exist!"
294+
Exception, match=r"Catalog Error: Table with name.*model_one.*does not exist"
295295
):
296296
context.fetchdf("SELECT * FROM db_1.first_schema.model_one")
297297

298298
with pytest.raises(
299-
Exception, match=r"Catalog Error: Table with name model_two does not exist!"
299+
Exception, match=r"Catalog Error: Table with name.*model_two.*does not exist"
300300
):
301301
context.engine_adapters["second"].fetchdf("SELECT * FROM db_2.second_schema.model_two")
302302
with pytest.raises(
303-
Exception, match=r"Catalog Error: Table with name model_one does not exist!"
303+
Exception, match=r"Catalog Error: Table with name.*model_one.*does not exist"
304304
):
305305
context.engine_adapters["second"].fetchdf("SELECT * FROM db_2.second_schema.model_one")
306306

0 commit comments

Comments
 (0)