mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2025-05-06 00:23:49 +03:00
Linter hints fixes
This commit is contained in:
parent
243333df2a
commit
e16892cb3b
1
.github/workflows/python-tests.yml
vendored
1
.github/workflows/python-tests.yml
vendored
|
@ -29,6 +29,7 @@ jobs:
|
|||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
clickhouse:
|
||||
image: yandex/clickhouse-server:${{ matrix.clickhouse-version }}
|
||||
ports:
|
||||
|
|
|
@ -94,7 +94,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
|
|||
return namedtuple("%sTuple" % cls.__name__, field_names, defaults=default_values)
|
||||
|
||||
@classmethod
|
||||
def objects_in(cls, database: Database)-> QuerySet:
|
||||
def objects_in(cls, database: Database) -> QuerySet:
|
||||
return QuerySet(cls, database)
|
||||
|
||||
@classmethod
|
||||
|
@ -121,7 +121,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
|
|||
return connections[db_alias]
|
||||
|
||||
@classmethod
|
||||
def get_django_model_serializer(cls, writable: bool= False, defaults: Optional[dict] = None
|
||||
def get_django_model_serializer(cls, writable: bool = False, defaults: Optional[dict] = None
|
||||
) -> Django2ClickHouseModelSerializer:
|
||||
serializer_cls = lazy_class_import(cls.django_model_serializer)
|
||||
return serializer_cls(cls, writable=writable, defaults=defaults)
|
||||
|
|
|
@ -28,7 +28,7 @@ def django_pg_returning_available(using: str) -> bool:
|
|||
:return: Boolean
|
||||
"""
|
||||
try:
|
||||
import django_pg_returning
|
||||
import django_pg_returning # noqa: F401
|
||||
return connections[using].vendor == 'postgresql'
|
||||
except ImportError:
|
||||
return False
|
||||
|
|
|
@ -48,9 +48,9 @@ class CollapsingMergeTree(InsertOnlyEngineMixin, infi_engines.CollapsingMergeTre
|
|||
def _get_final_versions_by_version(self, db_alias, model_cls, min_date, max_date, object_pks, date_col, columns):
|
||||
query = """
|
||||
SELECT {columns} FROM $table WHERE (`{pk_column}`, `{version_col}`) IN (
|
||||
SELECT `{pk_column}`, MAX(`{version_col}`)
|
||||
FROM $table
|
||||
PREWHERE `{date_col}` >= '{min_date}' AND `{date_col}` <= '{max_date}'
|
||||
SELECT `{pk_column}`, MAX(`{version_col}`)
|
||||
FROM $table
|
||||
PREWHERE `{date_col}` >= '{min_date}' AND `{date_col}` <= '{max_date}'
|
||||
AND `{pk_column}` IN ({object_pks})
|
||||
GROUP BY `{pk_column}`
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.db.models.signals import post_migrate
|
|||
from django.dispatch import receiver
|
||||
|
||||
# In order to support all operations import here
|
||||
from infi.clickhouse_orm.migrations import *
|
||||
from infi.clickhouse_orm.migrations import * # noqa F401, F403
|
||||
|
||||
from infi.clickhouse_orm.database import ServerError, DatabaseException
|
||||
from infi.clickhouse_orm.fields import StringField, DateField
|
||||
|
|
|
@ -83,7 +83,7 @@ class Storage:
|
|||
:param kwargs: Storage dependant arguments
|
||||
:return: Number of records in queue
|
||||
"""
|
||||
raise NotImplemented()
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_operations(self, import_key: str, count: int, **kwargs) -> List[Tuple[str, str]]:
|
||||
"""
|
||||
|
@ -94,7 +94,7 @@ class Storage:
|
|||
:param kwargs: Storage dependant arguments
|
||||
:return: A list of tuples (operation, pk) in incoming order.
|
||||
"""
|
||||
raise NotImplemented()
|
||||
raise NotImplementedError()
|
||||
|
||||
def register_operations(self, import_key: str, operation: str, *pks: Any) -> int:
|
||||
"""
|
||||
|
@ -135,21 +135,21 @@ class Storage:
|
|||
This method is used in tests to drop all storage data
|
||||
:return: None
|
||||
"""
|
||||
raise NotImplemented()
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_last_sync_time(self, import_key: str) -> Optional[datetime.datetime]:
|
||||
"""
|
||||
Gets the last time, sync has been executed
|
||||
:return: datetime.datetime if last sync has been. Otherwise - None.
|
||||
"""
|
||||
raise NotImplemented()
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_last_sync_time(self, import_key: str, dt: datetime.datetime) -> None:
|
||||
"""
|
||||
Sets successful sync time
|
||||
:return: None
|
||||
"""
|
||||
raise NotImplemented()
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class RedisStorage(with_metaclass(SingletonMeta, Storage)):
|
||||
|
|
|
@ -288,4 +288,4 @@ class SingletonMeta(type):
|
|||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(SingletonMeta, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
return cls._instances[cls]
|
||||
|
|
|
@ -15,9 +15,9 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'tests.settings')
|
|||
django.setup()
|
||||
|
||||
# This imports must be after django activation
|
||||
from django.db.models import F
|
||||
from tests.clickhouse_models import ClickHouseCollapseTestModel
|
||||
from tests.models import TestModel
|
||||
from django.db.models import F # noqa: E402
|
||||
from tests.clickhouse_models import ClickHouseCollapseTestModel # noqa: E402
|
||||
from tests.models import TestModel # noqa: E402
|
||||
|
||||
logger = logging.getLogger('django-clickhouse')
|
||||
|
||||
|
|
|
@ -48,5 +48,3 @@ class NamedTupleTest(TestCase):
|
|||
t2 = TestTuple(1, 2, 3)
|
||||
self.assertEqual(t1, t2)
|
||||
self.assertEqual((1, 2, 3), t1)
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import datetime
|
|||
from unittest import skipIf
|
||||
|
||||
import django
|
||||
from django.test import TransactionTestCase, TestCase
|
||||
from django.test import TransactionTestCase
|
||||
from django.utils.timezone import now
|
||||
|
||||
from tests.clickhouse_models import ClickHouseTestModel, ClickHouseSecondTestModel, ClickHouseCollapseTestModel, \
|
||||
|
|
|
@ -12,7 +12,7 @@ class StorageTest(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.storage.flush()
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
self.storage.flush()
|
||||
|
||||
|
@ -75,11 +75,10 @@ class StorageTest(TestCase):
|
|||
def test_locks(self):
|
||||
# Test that multiple can acquire locks in parallel
|
||||
# And single model can't
|
||||
l = self.storage.get_lock(ClickHouseTestModel.get_import_key())
|
||||
l.acquire()
|
||||
lock = self.storage.get_lock(ClickHouseTestModel.get_import_key())
|
||||
lock.acquire()
|
||||
with self.assertRaises(RedisLockTimeoutError):
|
||||
l.acquire()
|
||||
|
||||
l2 = self.storage.get_lock(ClickHouseCollapseTestModel.get_import_key())
|
||||
l2.acquire()
|
||||
lock.acquire()
|
||||
|
||||
lock_2 = self.storage.get_lock(ClickHouseCollapseTestModel.get_import_key())
|
||||
lock_2.acquire()
|
||||
|
|
|
@ -119,4 +119,3 @@ class TestSingletonMeta(TestCase):
|
|||
b = Single()
|
||||
self.assertEqual(a, b)
|
||||
self.assertEqual(2, b.test)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user