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