fix: Remove six (old compat layer for python2)

This commit is contained in:
Serg Tereshchenko 2022-07-13 23:14:28 +03:00
parent 10d2f123c8
commit 86b67c271e
9 changed files with 16 additions and 35 deletions

View file

@ -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

View file

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
import six
from django import VERSION
from django import forms
from django.core.exceptions import ImproperlyConfigured
@ -280,7 +278,7 @@ class TranslationField(object):
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

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Detect new translatable fields in all models and sync database structure.
@ -13,7 +12,6 @@ from django import VERSION
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
@ -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 == '':

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
The idea of MultilingualManager is taken from
django-linguo by Zach Mathew
@ -6,6 +5,7 @@ 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
@ -13,13 +13,9 @@ 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
@ -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):

View file

@ -7,7 +7,6 @@ from django.db.models import Manager, ForeignKey, OneToOneField, options
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 (
@ -52,7 +51,7 @@ class FieldsAggregationMetaClass(type):
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.

View file

@ -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
@ -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):

14
poetry.lock generated
View file

@ -382,14 +382,6 @@ category = "main"
optional = false
python-versions = "*"
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "sqlparse"
version = "0.4.2"
@ -453,7 +445,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes
[metadata]
lock-version = "1.1"
python-versions = ">=3.7,<4"
content-hash = "946cfcafe1b532f0f584925bfbcc9f47b5c1f58d42068518a1c57fffe67bd14c"
content-hash = "d7883ee15453e9e9d80231f44fd565ef9256a9114906d762dd9f762f2cbee596"
[metadata.files]
asgiref = [
@ -622,10 +614,6 @@ pytz = [
{file = "pytz-2022.1-py2.py3-none-any.whl", hash = "sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"},
{file = "pytz-2022.1.tar.gz", hash = "sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7"},
]
six = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
sqlparse = [
{file = "sqlparse-0.4.2-py3-none-any.whl", hash = "sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d"},
{file = "sqlparse-0.4.2.tar.gz", hash = "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae"},

View file

@ -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"
@ -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

View file

@ -28,7 +28,6 @@ license = New BSD
[options]
install_requires =
Django>=2.2
six
importlib-metadata; python_version<"3.8"
packages =
modeltranslation