73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
83
84
85
@@ -1064,33 +1055,14 @@
201
202
203
-204
-205
-206
-207
-208
-209
-210
-211
-212
-213
-214
-215
-216
-217
-218
-219
-220
-221
-222 | class SQLAlchemyBindManager:
+204
| class SQLAlchemyBindManager:
__binds: MutableMapping[str, Union[SQLAlchemyBind, SQLAlchemyAsyncBind]]
def __init__(
self,
config: Union[
- Mapping[str, Union[SQLAlchemyConfig, SQLAlchemyAsyncConfig]],
+ Mapping[str, SQLAlchemyConfig],
SQLAlchemyConfig,
- SQLAlchemyAsyncConfig,
],
) -> None:
self.__binds = {}
@@ -1100,18 +1072,10 @@
else:
self.__init_bind(DEFAULT_BIND_NAME, config)
- def __init_bind(
- self, name: str, config: Union[SQLAlchemyConfig, SQLAlchemyAsyncConfig]
- ):
- if not any(
- [
- isinstance(config, SQLAlchemyConfig),
- isinstance(config, SQLAlchemyAsyncConfig),
- ]
- ):
+ def __init_bind(self, name: str, config: SQLAlchemyConfig):
+ if not isinstance(config, SQLAlchemyConfig):
raise InvalidConfigError(
- f"Config for bind `{name}` is not a SQLAlchemyConfig"
- f" or SQLAlchemyAsyncConfig object"
+ f"Config for bind `{name}` is not a SQLAlchemyConfig" f"object"
)
engine_options: dict = config.engine_options or {}
@@ -1122,7 +1086,7 @@
session_options.setdefault("expire_on_commit", False)
session_options.setdefault("autobegin", False)
- if isinstance(config, SQLAlchemyAsyncConfig):
+ if config.async_engine:
self.__binds[name] = self.__build_async_bind(
engine_url=config.engine_url,
engine_options=engine_options,
@@ -1282,14 +1246,14 @@
|