Skip to content

Commit

Permalink
Merge pull request #646 from deschler/remove-six
Browse files Browse the repository at this point in the history
fix: Remove six (old compat layer for python2)
  • Loading branch information
last-partizan committed Jul 13, 2022
2 parents 10d2f12 + 86b67c2 commit d1d3c5c
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
if [[ $DB == postgres ]]; then
pip install -q psycopg2-binary
fi
pip install coverage six pytest pytest-django pytest-cov $(./get-django-version.py ${{ matrix.django }})
pip install coverage pytest pytest-django pytest-cov $(./get-django-version.py ${{ matrix.django }})
- name: Run tests
run: |
pytest --cov-report term
4 changes: 1 addition & 3 deletions modeltranslation/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
import six
from django import VERSION
from django import forms
from django.core.exceptions import ImproperlyConfigured
Expand Down Expand Up @@ -280,7 +278,7 @@ def deconstruct(self):
kwargs.update({'null': True})
if 'db_column' in kwargs:
kwargs['db_column'] = self.db_column
return six.text_type(self.name), path, args, kwargs
return self.name, path, args, kwargs

def clone(self):
from django.utils.module_loading import import_string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Detect new translatable fields in all models and sync database structure.
Expand All @@ -13,7 +12,6 @@
from django.core.management.base import BaseCommand
from django.core.management.color import no_style
from django.db import connection
from six import moves

from modeltranslation.settings import AVAILABLE_LANGUAGES
from modeltranslation.translator import translator
Expand All @@ -27,7 +25,7 @@ def ask_for_confirmation(sql_sentences, model_full_name, interactive):
while True:
prompt = '\nAre you sure that you want to execute the previous SQL: (y/n) [n]: '
if interactive:
answer = moves.input(prompt).strip()
answer = input(prompt).strip()
else:
answer = 'y'
if answer == '':
Expand Down
12 changes: 4 additions & 8 deletions modeltranslation/manager.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# -*- coding: utf-8 -*-
"""
The idea of MultilingualManager is taken from
django-linguo by Zach Mathew
https://github.com/zmathew/django-linguo
"""
import itertools
from functools import reduce

from django import VERSION
from django.contrib.admin.utils import get_model_from_relation
from django.core.exceptions import FieldDoesNotExist
from django.db import models
from django.db.models.expressions import Col
from django.db.models.lookups import Lookup
from django.db.models.query import (
QuerySet,
ValuesIterable,
create_namedtuple_class,
)
from django.db.models.query import QuerySet, ValuesIterable
from django.db.models.utils import create_namedtuple_class
from django.utils.tree import Node
from six import moves

from modeltranslation import settings
from modeltranslation.fields import TranslationField
Expand Down Expand Up @@ -126,7 +122,7 @@ def append_lookup_keys(model, fields):
new_field = (field,)
new_fields.append(new_field)

return moves.reduce(set.union, new_fields, set())
return reduce(set.union, new_fields, set())


def rewrite_order_lookup_key(model, lookup_key):
Expand Down
3 changes: 1 addition & 2 deletions modeltranslation/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from django.db.models.base import ModelBase
from django.db.models.signals import post_init
from django.utils.functional import cached_property
from six import with_metaclass

from modeltranslation import settings as mt_settings
from modeltranslation.fields import (
Expand Down Expand Up @@ -52,7 +51,7 @@ def __new__(cls, name, bases, attrs):
return super(FieldsAggregationMetaClass, cls).__new__(cls, name, bases, attrs)


class TranslationOptions(with_metaclass(FieldsAggregationMetaClass, object)):
class TranslationOptions(metaclass=FieldsAggregationMetaClass):
"""
Translatable fields are declared by registering a model using
``TranslationOptions`` class with appropriate ``fields`` attribute.
Expand Down
4 changes: 1 addition & 3 deletions modeltranslation/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
from contextlib import contextmanager

import six
from django.utils.encoding import force_str
from django.utils.translation import get_language as _get_language
from django.utils.translation import get_language_info
Expand Down Expand Up @@ -54,7 +52,7 @@ def _build_localized_verbose_name(verbose_name, lang):
return force_str('%s [%s]') % (force_str(verbose_name), lang)


build_localized_verbose_name = lazy(_build_localized_verbose_name, six.text_type)
build_localized_verbose_name = lazy(_build_localized_verbose_name, str)


def _join_css_class(bits, offset):
Expand Down
14 changes: 1 addition & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ packages = [
[tool.poetry.dependencies]
python = ">=3.7,<4"
django = ">=2.2"
six = "^1.15.0"

[tool.poetry.dev-dependencies]
pdbpp = "^0.10.2"
Expand All @@ -26,3 +25,9 @@ django-types = "^0.15.0"
[tool.black]
line-length = 100
skip-string-normalization = true

[tool.isort]
line_length = 100
multi_line_output = 3
skip_gitignore = true
include_trailing_comma = true
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ license = New BSD
[options]
install_requires =
Django>=2.2
six
importlib-metadata; python_version<"3.8"
packages =
modeltranslation
Expand Down

0 comments on commit d1d3c5c

Please sign in to comment.