Skip to content

Commit

Permalink
1. Removed six dependency
Browse files Browse the repository at this point in the history
2. pytz and typing are installed for old python versions only
3. psycopg2-bynary is installed in test environment instead of psycopg2
  • Loading branch information
M1ha-Shvn committed Jul 6, 2021
1 parent 717c74c commit 893ffaf
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 27 deletions.
5 changes: 2 additions & 3 deletions docs/basic_information.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ It is based on [infi.clickhouse-orm](https://github.com/Infinidat/infi.clickhous
* [Django](https://docs.djangoproject.com/) 1.7+
* [Yandex ClickHouse](https://clickhouse.yandex/)
* [infi.clickhouse-orm](https://github.com/Infinidat/infi.clickhouse_orm)
* [pytz](https://pypi.org/project/pytz/)
* [six](https://pypi.org/project/six/)
* [typing](https://pypi.org/project/typing/)
* [pytz](https://pypi.org/project/pytz/) for python before 3.3
* [typing](https://pypi.org/project/typing/) for python before 3.5
* [psycopg2](https://www.psycopg.org/)
* [celery](http://www.celeryproject.org/)
* [statsd](https://pypi.org/project/statsd/)
Expand Down
12 changes: 6 additions & 6 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
celery
Django (>=1.7)
pytz
six
typing
psycopg2
infi.clickhouse-orm
celery
pytz; python_version < '3.3'
statsd
typing; python_version < '3.5'

psycopg2-binary
django-pg-returning
django-pg-bulk-update
redis
redis
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
celery
Django (>=1.7)
pytz
six
typing; python_version < "3.5"
infi.clickhouse-orm
celery
pytz; python_version < '3.3'
statsd
typing; python_version < '3.5'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='django-clickhouse',
version='1.0.3',
version='1.0.4',
packages=['django_clickhouse'],
package_dir={'': 'src'},
url='https://github.com/carrotquest/django-clickhouse',
Expand Down
3 changes: 1 addition & 2 deletions src/django_clickhouse/clickhouse_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from django.db.models import Model as DjangoModel, QuerySet as DjangoQuerySet
from infi.clickhouse_orm.engines import CollapsingMergeTree
from infi.clickhouse_orm.models import Model as InfiModel, ModelBase as InfiModelBase
from six import with_metaclass
from statsd.defaults.django import statsd

from .compatibility import namedtuple
Expand Down Expand Up @@ -41,7 +40,7 @@ def __new__(cls, *args, **kwargs):
return res


class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
class ClickHouseModel(InfiModel, metaclass=ClickHouseModelMeta):
"""
Base model for all other models
"""
Expand Down
1 change: 0 additions & 1 deletion src/django_clickhouse/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from infi.clickhouse_orm.database import Database as InfiDatabase, DatabaseException
from infi.clickhouse_orm.utils import parse_tsv
from six import next
from io import BytesIO
from statsd.defaults.django import statsd

Expand Down
3 changes: 1 addition & 2 deletions src/django_clickhouse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from typing import Optional, Any, Type, Set

import six
from django.db import transaction
from django.db.models import QuerySet as DjangoQuerySet, Model as DjangoModel, Manager as DjangoManager
from django.db.models.manager import BaseManager
Expand Down Expand Up @@ -64,7 +63,7 @@ def _update_returning_param(self, returning):
pk_name = self.model._meta.pk.name
if returning is None:
returning = pk_name
elif isinstance(returning, six.string_types):
elif isinstance(returning, str):
returning = [pk_name, returning]
else:
returning = list(returning) + [pk_name]
Expand Down
3 changes: 1 addition & 2 deletions src/django_clickhouse/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Type

import random
import six
from infi.clickhouse_orm.migrations import Operation, DropTable, CreateTable

from .clickhouse_models import ClickHouseModel
Expand Down Expand Up @@ -47,7 +46,7 @@ def allow_migrate(self, db_alias: str, app_label: str, operation: Operation,

if hints.get('model'):
model = '%s.%s.%s' % (app_label, config.MODELS_MODULE, hints['model']) \
if isinstance(hints['model'], six.string_types) else hints['model']
if isinstance(hints['model'], str) else hints['model']

model = lazy_class_import(model)

Expand Down
3 changes: 1 addition & 2 deletions src/django_clickhouse/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import Any, Optional, List, Tuple

import os
from six import with_metaclass
from statsd.defaults.django import statsd

from .configuration import config
Expand Down Expand Up @@ -152,7 +151,7 @@ def set_last_sync_time(self, import_key: str, dt: datetime.datetime) -> None:
raise NotImplemented()


class RedisStorage(with_metaclass(SingletonMeta, Storage)):
class RedisStorage(Storage, metaclass=SingletonMeta):
"""
Fast in-memory storage made on bases of redis and redis-py library.
Requires:
Expand Down
3 changes: 1 addition & 2 deletions src/django_clickhouse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Union, Any, Optional, TypeVar, Set, Dict, Iterable, Tuple, Iterator, Callable, List

import pytz
import six
from importlib import import_module
from importlib.util import find_spec
from django.db.models import Model as DjangoModel
Expand Down Expand Up @@ -76,7 +75,7 @@ def lazy_class_import(obj: Union[str, Any]) -> Any:
:param obj: A string class path or object to return
:return: Imported object
"""
if isinstance(obj, six.string_types):
if isinstance(obj, str):
module_name, obj_name = obj.rsplit('.', 1)
module = import_module(module_name)

Expand Down
3 changes: 1 addition & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytz
from django.test import TestCase
from six import with_metaclass

from django_clickhouse.models import ClickHouseSyncModel
from django_clickhouse.utils import get_tz_offset, format_datetime, lazy_class_import, int_ranges, exec_in_parallel, \
Expand Down Expand Up @@ -110,7 +109,7 @@ def _test_func(x):

class TestSingletonMeta(TestCase):
def test_singleton(self):
class Single(with_metaclass(SingletonMeta)):
class Single(metaclass=SingletonMeta):
def __init__(self):
self.test = 1

Expand Down

0 comments on commit 893ffaf

Please sign in to comment.