Skip to content
Snippets Groups Projects
Commit c6737998 authored by Martin Mareš's avatar Martin Mareš
Browse files

DB: Oživen hack pro mypy

Nedává moc smysl, protože TypeEngine není parametrizovaný typ ...
ale kupodivu to type-checkerem projde a zamaskuje to problémy s enumy.
parent 906bd960
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import locale ...@@ -8,7 +8,7 @@ import locale
import os import os
import re import re
from sqlalchemy import \ from sqlalchemy import \
Boolean, Column, DateTime, Enum, ForeignKey, Integer, String, Text, UniqueConstraint, \ Boolean, Column, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, \
text, func, \ text, func, \
create_engine, inspect, select create_engine, inspect, select
from sqlalchemy.engine import Engine from sqlalchemy.engine import Engine
...@@ -27,6 +27,16 @@ import mo.config as config ...@@ -27,6 +27,16 @@ import mo.config as config
from mo.place_level import place_levels, PlaceLevel from mo.place_level import place_levels, PlaceLevel
from mo.util_format import timeformat_short, timedelta, time_and_timedelta from mo.util_format import timeformat_short, timedelta, time_and_timedelta
# HACK: Work-around for https://github.com/dropbox/sqlalchemy-stubs/issues/114
from typing import TYPE_CHECKING, TypeVar, Type
if TYPE_CHECKING:
from sqlalchemy.sql.type_api import TypeEngine
T = TypeVar('T')
class Enum(TypeEngine[T]):
def __init__(self, enum: Type[T], **kwargs: Any) -> None: ...
else:
from sqlalchemy import Enum
# Funkce f_unaccent je definovaná v db.ddl, naučme Alchymii volat ji: # Funkce f_unaccent je definovaná v db.ddl, naučme Alchymii volat ji:
class f_unaccent(ReturnTypeFromArgs): class f_unaccent(ReturnTypeFromArgs):
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment