@@ -22,37 +22,15 @@ from sqlalchemy.sql.expression import Select as _Select
2222
2323_TSelect = TypeVar("_TSelect")
2424
25- # Workaround Generics incompatibility in Python 3.6
26- # Ref: https://github.com/python/typing/issues/449#issuecomment-316061322
27- if sys.version_info.minor >= 7:
28-
29- class Select(_Select, Generic[_TSelect]):
30- inherit_cache = True
31-
32- # This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different
33- # purpose. This is the same as a normal SQLAlchemy Select class where there's only one
34- # entity, so the result will be converted to a scalar by default. This way writing
35- # for loops on the results will feel natural.
36- class SelectOfScalar(_Select, Generic[_TSelect]):
37- inherit_cache = True
38-
39- else:
40- from typing import GenericMeta # type: ignore
41-
42- class GenericSelectMeta(GenericMeta, _Select.__class__): # type: ignore
43- pass
44-
45- class _Py36Select(_Select, Generic[_TSelect], metaclass=GenericSelectMeta):
46- inherit_cache = True
47-
48- class _Py36SelectOfScalar(_Select, Generic[_TSelect], metaclass=GenericSelectMeta):
49- inherit_cache = True
50-
51- # Cast them for editors to work correctly, from several tricks tried, this works
52- # for both VS Code and PyCharm
53- Select = cast("Select", _Py36Select) # type: ignore
54- SelectOfScalar = cast("SelectOfScalar", _Py36SelectOfScalar) # type: ignore
55-
25+ class Select(_Select, Generic[_TSelect]):
26+ inherit_cache = True
27+
28+ # This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different
29+ # purpose. This is the same as a normal SQLAlchemy Select class where there's only one
30+ # entity, so the result will be converted to a scalar by default. This way writing
31+ # for loops on the results will feel natural.
32+ class SelectOfScalar(_Select, Generic[_TSelect]):
33+ inherit_cache = True
5634
5735if TYPE_CHECKING: # pragma: no cover
5836 from ..main import SQLModel
0 commit comments