Bump SQLAlchemy to 2.0.39 (#140473)

* Bump SQLAlchemy to 2.0.39

changelog: https://docs.sqlalchemy.org/en/20/changelog/changelog_20.html#change-2.0.39

* fix typing
This commit is contained in:
J. Nick Koston 2025-03-12 13:09:41 -10:00 committed by GitHub
parent 1f6658fca0
commit e78dc486f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 20 additions and 15 deletions

View File

@ -203,11 +203,11 @@ UINT_32_TYPE = BigInteger().with_variant(
"mariadb",
)
JSON_VARIANT_CAST = Text().with_variant(
postgresql.JSON(none_as_null=True), # type: ignore[no-untyped-call]
postgresql.JSON(none_as_null=True),
"postgresql",
)
JSONB_VARIANT_CAST = Text().with_variant(
postgresql.JSONB(none_as_null=True), # type: ignore[no-untyped-call]
postgresql.JSONB(none_as_null=True),
"postgresql",
)
DATETIME_TYPE = (

View File

@ -7,7 +7,7 @@
"iot_class": "local_push",
"quality_scale": "internal",
"requirements": [
"SQLAlchemy==2.0.38",
"SQLAlchemy==2.0.39",
"fnv-hash-fast==1.4.0",
"psutil-home-assistant==0.0.1"
]

View File

@ -9,7 +9,7 @@ from dataclasses import dataclass, replace as dataclass_replace
from datetime import timedelta
import logging
from time import time
from typing import TYPE_CHECKING, Any, cast, final
from typing import TYPE_CHECKING, Any, TypedDict, cast, final
from uuid import UUID
import sqlalchemy
@ -712,6 +712,11 @@ def _modify_columns(
raise
class _FKAlterDict(TypedDict):
old_fk: ForeignKeyConstraint
columns: list[str]
def _update_states_table_with_foreign_key_options(
session_maker: Callable[[], Session], engine: Engine
) -> None:
@ -729,7 +734,7 @@ def _update_states_table_with_foreign_key_options(
inspector = sqlalchemy.inspect(engine)
tmp_states_table = Table(TABLE_STATES, MetaData())
alters = [
alters: list[_FKAlterDict] = [
{
"old_fk": ForeignKeyConstraint(
(), (), name=foreign_key["name"], table=tmp_states_table
@ -755,14 +760,14 @@ def _update_states_table_with_foreign_key_options(
with session_scope(session=session_maker()) as session:
try:
connection = session.connection()
connection.execute(DropConstraint(alter["old_fk"])) # type: ignore[no-untyped-call]
connection.execute(DropConstraint(alter["old_fk"]))
for fkc in states_key_constraints:
if fkc.column_keys == alter["columns"]:
# AddConstraint mutates the constraint passed to it, we need to
# undo that to avoid changing the behavior of the table schema.
# https://github.com/sqlalchemy/sqlalchemy/blob/96f1172812f858fead45cdc7874abac76f45b339/lib/sqlalchemy/sql/ddl.py#L746-L748
create_rule = fkc._create_rule # noqa: SLF001
add_constraint = AddConstraint(fkc) # type: ignore[no-untyped-call]
add_constraint = AddConstraint(fkc)
fkc._create_rule = create_rule # noqa: SLF001
connection.execute(add_constraint)
except (InternalError, OperationalError):
@ -800,7 +805,7 @@ def _drop_foreign_key_constraints(
with session_scope(session=session_maker()) as session:
try:
connection = session.connection()
connection.execute(DropConstraint(drop)) # type: ignore[no-untyped-call]
connection.execute(DropConstraint(drop))
except (InternalError, OperationalError):
_LOGGER.exception(
"Could not drop foreign constraints in %s table on %s",
@ -845,7 +850,7 @@ def _restore_foreign_key_constraints(
# undo that to avoid changing the behavior of the table schema.
# https://github.com/sqlalchemy/sqlalchemy/blob/96f1172812f858fead45cdc7874abac76f45b339/lib/sqlalchemy/sql/ddl.py#L746-L748
create_rule = constraint._create_rule # noqa: SLF001
add_constraint = AddConstraint(constraint) # type: ignore[no-untyped-call]
add_constraint = AddConstraint(constraint)
constraint._create_rule = create_rule # noqa: SLF001
try:
_add_constraint(session_maker, add_constraint, table, column)

View File

@ -6,5 +6,5 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/sql",
"iot_class": "local_polling",
"requirements": ["SQLAlchemy==2.0.38", "sqlparse==0.5.0"]
"requirements": ["SQLAlchemy==2.0.39", "sqlparse==0.5.0"]
}

View File

@ -61,7 +61,7 @@ PyTurboJPEG==1.7.5
PyYAML==6.0.2
requests==2.32.3
securetar==2025.2.1
SQLAlchemy==2.0.38
SQLAlchemy==2.0.39
standard-aifc==3.13.0
standard-telnetlib==3.13.0
typing-extensions>=4.12.2,<5.0

View File

@ -67,7 +67,7 @@ dependencies = [
"PyYAML==6.0.2",
"requests==2.32.3",
"securetar==2025.2.1",
"SQLAlchemy==2.0.38",
"SQLAlchemy==2.0.39",
"standard-aifc==3.13.0",
"standard-telnetlib==3.13.0",
"typing-extensions>=4.12.2,<5.0",

2
requirements.txt generated
View File

@ -39,7 +39,7 @@ python-slugify==8.0.4
PyYAML==6.0.2
requests==2.32.3
securetar==2025.2.1
SQLAlchemy==2.0.38
SQLAlchemy==2.0.39
standard-aifc==3.13.0
standard-telnetlib==3.13.0
typing-extensions>=4.12.2,<5.0

2
requirements_all.txt generated
View File

@ -116,7 +116,7 @@ RtmAPI==0.7.2
# homeassistant.components.recorder
# homeassistant.components.sql
SQLAlchemy==2.0.38
SQLAlchemy==2.0.39
# homeassistant.components.tami4
Tami4EdgeAPI==3.0

View File

@ -110,7 +110,7 @@ RtmAPI==0.7.2
# homeassistant.components.recorder
# homeassistant.components.sql
SQLAlchemy==2.0.38
SQLAlchemy==2.0.39
# homeassistant.components.tami4
Tami4EdgeAPI==3.0