r"""Return the current :class:`.Session`, creating it using the :attr:`.scoped_session.session_factory` if not present. :param \**kw: Keyword arguments will be passed to the :attr:`.scoped_session.session_factory` callable, if an existing :class:`.Session` is not p
(self, **kw: Any)
| 204 | return self.registry() |
| 205 | |
| 206 | def __call__(self, **kw: Any) -> _S: |
| 207 | r"""Return the current :class:`.Session`, creating it |
| 208 | using the :attr:`.scoped_session.session_factory` if not present. |
| 209 | |
| 210 | :param \**kw: Keyword arguments will be passed to the |
| 211 | :attr:`.scoped_session.session_factory` callable, if an existing |
| 212 | :class:`.Session` is not present. If the :class:`.Session` is present |
| 213 | and keyword arguments have been passed, |
| 214 | :exc:`~sqlalchemy.exc.InvalidRequestError` is raised. |
| 215 | |
| 216 | """ |
| 217 | if kw: |
| 218 | if self.registry.has(): |
| 219 | raise sa_exc.InvalidRequestError( |
| 220 | "Scoped session is already present; " |
| 221 | "no new arguments may be specified." |
| 222 | ) |
| 223 | else: |
| 224 | sess = self.session_factory(**kw) |
| 225 | self.registry.set(sess) |
| 226 | else: |
| 227 | sess = self.registry() |
| 228 | if not self._support_async and sess._is_asyncio: |
| 229 | warn_deprecated( |
| 230 | "Using `scoped_session` with asyncio is deprecated and " |
| 231 | "will raise an error in a future version. " |
| 232 | "Please use `async_scoped_session` instead.", |
| 233 | "1.4.23", |
| 234 | ) |
| 235 | return sess |
| 236 | |
| 237 | def configure(self, **kwargs: Any) -> None: |
| 238 | """reconfigure the :class:`.sessionmaker` used by this |
nothing calls this directly
no test coverage detected