File: my_lib.py

package info (click to toggle)
litestar 2.19.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,500 kB
  • sloc: python: 70,169; makefile: 254; javascript: 105; sh: 60
file content (24 lines) | stat: -rw-r--r-- 630 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import annotations

from typing import Any

from sqlalchemy.orm import DeclarativeBase

from litestar.plugins.sqlalchemy import base, mixins


class _Base(base.CommonTableAttributes, mixins.UUIDPrimaryKey, DeclarativeBase):
    """Fake base SQLAlchemy model for typing purposes."""


Base: _Base


def __getattr__(name: str) -> Any:
    if name == "Base":
        return type(
            "Base",
            (base.CommonTableAttributes, mixins.UUIDPrimaryKey, DeclarativeBase),
            {"registry": base.create_registry()},
        )
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")