brain_sqlalchemy.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  2. # For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
  3. # Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
  4. from astroid import nodes
  5. from astroid.brain.helpers import register_module_extender
  6. from astroid.builder import parse
  7. from astroid.manager import AstroidManager
  8. def _session_transform() -> nodes.Module:
  9. return parse(
  10. """
  11. from sqlalchemy.orm.session import Session
  12. class sessionmaker:
  13. def __init__(
  14. self,
  15. bind=None,
  16. class_=Session,
  17. autoflush=True,
  18. autocommit=False,
  19. expire_on_commit=True,
  20. info=None,
  21. **kw
  22. ):
  23. return
  24. def __call__(self, **local_kw):
  25. return Session()
  26. def configure(self, **new_kw):
  27. return
  28. return Session()
  29. """
  30. )
  31. def register(manager: AstroidManager) -> None:
  32. register_module_extender(manager, "sqlalchemy.orm.session", _session_transform)