diff --git a/captcha/client.py b/captcha/client.py index f8bfcb9b..09af8591 100644 --- a/captcha/client.py +++ b/captcha/client.py @@ -3,10 +3,9 @@ from django.conf import settings from captcha._compat import ( - build_opener, ProxyHandler, PY2, Request, urlencode, urlopen + build_opener, ProxyHandler, PY2, Request, urlencode ) from captcha.constants import DEFAULT_RECAPTCHA_DOMAIN -from captcha.decorators import generic_deprecation RECAPTCHA_SUPPORTED_LANUAGES = ("en", "nl", "fr", "de", "pt", "ru", "es", "tr") diff --git a/captcha/fields.py b/captcha/fields.py index c0fdc323..ce938732 100644 --- a/captcha/fields.py +++ b/captcha/fields.py @@ -1,20 +1,21 @@ import logging -import os -import socket import sys -import warnings +import django from django import forms from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ValidationError -from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy as _ + +if django.VERSION[0] < 2: + from django.utils.translation import ugettext_lazy as _ +else: + from django.utils.translation import gettext_lazy as _ from captcha import client -from captcha._compat import HTTPError, urlencode +from captcha._compat import HTTPError from captcha.constants import TEST_PRIVATE_KEY, TEST_PUBLIC_KEY -from captcha.widgets import ReCaptchaV2Checkbox, ReCaptchaBase, ReCaptchaV3 +from captcha.widgets import ReCaptchaV2Checkbox, ReCaptchaBase logger = logging.getLogger(__name__) diff --git a/captcha/tests/test_client.py b/captcha/tests/test_client.py index 557ae0c3..feefb115 100644 --- a/captcha/tests/test_client.py +++ b/captcha/tests/test_client.py @@ -6,10 +6,9 @@ from mock import patch, PropertyMock, MagicMock from django import forms -from django.conf import settings from django.test import TestCase, override_settings -from captcha import client, constants, fields +from captcha import client, fields class DefaultForm(forms.Form): diff --git a/captcha/tests/test_fields.py b/captcha/tests/test_fields.py index 245e5be3..44d00b0e 100644 --- a/captcha/tests/test_fields.py +++ b/captcha/tests/test_fields.py @@ -1,7 +1,3 @@ -import os -import uuid -import warnings - try: from unittest.mock import patch, PropertyMock, MagicMock except ImportError: @@ -11,7 +7,7 @@ from django.core.exceptions import ImproperlyConfigured from django.test import TestCase, override_settings -from captcha import fields, widgets, constants +from captcha import fields, widgets from captcha._compat import HTTPError from captcha.client import RecaptchaResponse diff --git a/captcha/tests/tests.py b/captcha/tests/tests.py index 1f74b20e..981cf45d 100644 --- a/captcha/tests/tests.py +++ b/captcha/tests/tests.py @@ -3,7 +3,6 @@ except ImportError: pass -from django.conf import settings from django.core.checks import Error from django.core.exceptions import ImproperlyConfigured from django.test import TestCase, override_settings diff --git a/captcha/widgets.py b/captcha/widgets.py index d75f3314..86b64a4f 100644 --- a/captcha/widgets.py +++ b/captcha/widgets.py @@ -1,10 +1,7 @@ -import json import uuid from django.conf import settings from django.forms import widgets -from django.utils.safestring import mark_safe -from django.utils.translation import get_language from captcha._compat import urlencode from captcha.constants import DEFAULT_RECAPTCHA_DOMAIN