summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.pre-commit-config.yaml8
-rw-r--r--.zuul.yaml1
-rw-r--r--lower-constraints.txt45
-rw-r--r--oslo_i18n/_gettextutils.py4
-rw-r--r--oslo_i18n/_message.py8
-rw-r--r--oslo_i18n/_translate.py4
-rw-r--r--oslo_i18n/fixture.py3
-rw-r--r--oslo_i18n/tests/test_factory.py40
-rw-r--r--oslo_i18n/tests/test_fixture.py3
-rw-r--r--oslo_i18n/tests/test_gettextutils.py11
-rw-r--r--oslo_i18n/tests/test_handler.py4
-rw-r--r--oslo_i18n/tests/test_message.py9
-rw-r--r--oslo_i18n/tests/test_public_api.py4
-rw-r--r--requirements.txt1
-rw-r--r--tox.ini10
15 files changed, 28 insertions, 127 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9d94556..66a040f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -27,9 +27,13 @@ repos:
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- - repo: https://gitlab.com/pycqa/flake8
- rev: 181bb46098dddf7e2d45319ea654b4b4d58c2840 # 3.8.3
+ - repo: local
hooks:
- id: flake8
+ name: flake8
additional_dependencies:
- hacking>=3.0.1,<3.1.0
+ language: python
+ entry: flake8
+ files: '^.*\.py$'
+ exclude: '^(doc|releasenotes|tools)/.*$'
diff --git a/.zuul.yaml b/.zuul.yaml
index 896febc..20a7b6a 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -3,7 +3,6 @@
- check-requirements
- lib-forward-testing-python3
- openstack-cover-jobs
- - openstack-lower-constraints-jobs
- openstack-python3-wallaby-jobs
- periodic-stable-jobs
- publish-openstack-docs-pti
diff --git a/lower-constraints.txt b/lower-constraints.txt
deleted file mode 100644
index 29580e8..0000000
--- a/lower-constraints.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-alabaster==0.7.10
-appdirs==1.3.0
-bandit==1.4.0
-coverage==4.0
-debtcollector==1.2.0
-docutils==0.11
-dulwich==0.15.0
-extras==1.0.0
-fixtures==3.0.0
-gitdb==0.6.4
-GitPython==1.0.1
-imagesize==0.7.1
-iso8601==0.1.11
-Jinja2==2.10
-keystoneauth1==3.4.0
-linecache2==1.0.0
-MarkupSafe==1.0
-mox3==0.20.0
-netaddr==0.7.18
-openstackdocstheme==2.2.1
-os-client-config==1.28.0
-oslo.config==5.2.0
-oslotest==3.2.0
-pbr==2.0.0
-Pygments==2.2.0
-python-mimeparse==1.6.0
-python-subunit==1.0.0
-pytz==2013.6
-PyYAML==3.12
-reno==3.1.0
-requests==2.14.2
-requestsexceptions==1.2.0
-rfc3986==0.3.1
-six==1.10.0
-smmap==0.9.0
-snowballstemmer==1.2.1
-Sphinx==2.0.0
-sphinxcontrib-websupport==1.0.1
-stestr==2.0.0
-stevedore==1.20.0
-testscenarios==0.4
-testtools==2.2.0
-traceback2==1.4.0
-unittest2==1.1.0
-wrapt==1.7.0
diff --git a/oslo_i18n/_gettextutils.py b/oslo_i18n/_gettextutils.py
index 9872a9c..19f093b 100644
--- a/oslo_i18n/_gettextutils.py
+++ b/oslo_i18n/_gettextutils.py
@@ -44,9 +44,9 @@ def install(domain):
:param domain: the translation domain
"""
- from six import moves
+ import builtins
tf = _factory.TranslatorFactory(domain)
- moves.builtins.__dict__['_'] = tf.primary
+ builtins.__dict__['_'] = tf.primary
_AVAILABLE_LANGUAGES = {}
diff --git a/oslo_i18n/_message.py b/oslo_i18n/_message.py
index 1d94e8d..a73992e 100644
--- a/oslo_i18n/_message.py
+++ b/oslo_i18n/_message.py
@@ -23,8 +23,6 @@ import logging
import os
import warnings
-import six
-
from oslo_i18n import _locale
from oslo_i18n import _translate
@@ -35,7 +33,7 @@ CONTEXT_SEPARATOR = "\x04"
LOG = logging.getLogger(__name__)
-class Message(six.text_type):
+class Message(str):
"""A Message object is a unicode object that can be translated.
Translation of Message is done explicitly using the translate() method.
@@ -184,7 +182,7 @@ class Message(six.text_type):
# by the base class (i.e. unicode()), the only thing we do here is
# save the original msgid and the parameters in case of a translation
params = self._sanitize_mod_params(other)
- unicode_mod = self._safe_translate(six.text_type(self), params)
+ unicode_mod = self._safe_translate(str(self), params)
modded = Message(self.msgid,
msgtext=unicode_mod,
params=params,
@@ -221,7 +219,7 @@ class Message(six.text_type):
except Exception:
# Fallback to casting to unicode this will handle the
# python code-like objects that can't be deep-copied
- return six.text_type(param)
+ return str(param)
def __add__(self, other):
from oslo_i18n._i18n import _
diff --git a/oslo_i18n/_translate.py b/oslo_i18n/_translate.py
index 9d68beb..2a35741 100644
--- a/oslo_i18n/_translate.py
+++ b/oslo_i18n/_translate.py
@@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
-
__all__ = [
'translate',
]
@@ -41,7 +39,7 @@ def translate(obj, desired_locale=None):
if not isinstance(message, _message.Message):
# If the object to translate is not already translatable,
# let's first get its unicode representation
- message = six.text_type(obj)
+ message = str(obj)
if isinstance(message, _message.Message):
# Even after unicoding() we still need to check if we are
# running with translatable unicode before translating
diff --git a/oslo_i18n/fixture.py b/oslo_i18n/fixture.py
index 35dc694..5c5fddc 100644
--- a/oslo_i18n/fixture.py
+++ b/oslo_i18n/fixture.py
@@ -16,7 +16,6 @@
import gettext
import fixtures
-import six
from oslo_i18n import _lazy
from oslo_i18n import _message
@@ -65,7 +64,7 @@ class Translation(fixtures.Fixture):
:type msg: str or unicode
"""
- return six.text_type(msg)
+ return str(msg)
class ToggleLazy(fixtures.Fixture):
diff --git a/oslo_i18n/tests/test_factory.py b/oslo_i18n/tests/test_factory.py
index 34effb5..fbc585b 100644
--- a/oslo_i18n/tests/test_factory.py
+++ b/oslo_i18n/tests/test_factory.py
@@ -17,7 +17,6 @@
from unittest import mock
from oslotest import base as test_base
-import six
from oslo_i18n import _factory
from oslo_i18n import _lazy
@@ -62,48 +61,9 @@ class TranslatorFactoryTest(test_base.BaseTestCase):
r = tf.primary('some text')
self.assertNotIsInstance(r, _message.Message)
- def test_py3(self):
- _lazy.enable_lazy(False)
- with mock.patch.object(six, 'PY3', True):
- with mock.patch('gettext.translation') as translation:
- trans = mock.Mock()
- translation.return_value = trans
- trans.ugettext.side_effect = AssertionError(
- 'should have called gettext')
- tf = _factory.TranslatorFactory('domain')
- tf.primary('some text')
- trans.gettext.assert_called_with('some text')
-
def test_log_level_domain_name(self):
with mock.patch.object(_factory.TranslatorFactory,
'_make_translation_func') as mtf:
tf = _factory.TranslatorFactory('domain')
tf._make_log_translation_func('mylevel')
mtf.assert_called_with('domain-log-mylevel')
-
- def test_contextual_form_py3(self):
- _lazy.enable_lazy(False)
- with mock.patch.object(six, 'PY3', True):
- with mock.patch('gettext.translation') as translation:
- trans = mock.Mock()
- translation.return_value = trans
- trans.ugettext.side_effect = AssertionError(
- 'should have called gettext')
- trans.gettext.return_value = "some text"
- tf = _factory.TranslatorFactory('domain')
- tf.contextual_form('context', 'some text')
- trans.gettext.assert_called_with(
- "%s%s%s" % ('context', CONTEXT_SEPARATOR, 'some text'))
-
- def test_plural_form_py3(self):
- _lazy.enable_lazy(False)
- with mock.patch.object(six, 'PY3', True):
- with mock.patch('gettext.translation') as translation:
- trans = mock.Mock()
- translation.return_value = trans
- trans.ungettext.side_effect = AssertionError(
- 'should have called ngettext')
- tf = _factory.TranslatorFactory('domain')
- tf.plural_form('single', 'plural', 1)
- trans.ngettext.assert_called_with(
- 'single', 'plural', 1)
diff --git a/oslo_i18n/tests/test_fixture.py b/oslo_i18n/tests/test_fixture.py
index a152ce3..5b4eaa5 100644
--- a/oslo_i18n/tests/test_fixture.py
+++ b/oslo_i18n/tests/test_fixture.py
@@ -13,7 +13,6 @@
# under the License.
from oslotest import base as test_base
-import six
import oslo_i18n
from oslo_i18n import _gettextutils
@@ -38,7 +37,7 @@ class TranslationFixtureTest(test_base.BaseTestCase):
def test_immediate(self):
msg = self.trans_fixture.immediate('this is a lazy message')
self.assertNotIsInstance(msg, _message.Message)
- self.assertIsInstance(msg, six.text_type)
+ self.assertIsInstance(msg, str)
self.assertEqual(u'this is a lazy message', msg)
diff --git a/oslo_i18n/tests/test_gettextutils.py b/oslo_i18n/tests/test_gettextutils.py
index 4e0999b..580aba9 100644
--- a/oslo_i18n/tests/test_gettextutils.py
+++ b/oslo_i18n/tests/test_gettextutils.py
@@ -14,12 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+import builtins
import gettext
import logging
from unittest import mock
from oslotest import base as test_base
-import six
from oslo_i18n import _factory
from oslo_i18n import _gettextutils
@@ -49,8 +49,7 @@ class GettextTest(test_base.BaseTestCase):
def test__gettextutils_install(self):
_gettextutils.install('blaa')
_lazy.enable_lazy(False)
- self.assertTrue(isinstance(self.t.primary('A String'),
- six.text_type))
+ self.assertTrue(isinstance(self.t.primary('A String'), str))
_gettextutils.install('blaa')
_lazy.enable_lazy(True)
@@ -68,10 +67,10 @@ class GettextTest(test_base.BaseTestCase):
with mock.patch('os.environ.get') as environ_get:
with mock.patch('gettext.install'):
environ_get.return_value = '/foo/bar'
- if '_' in six.moves.builtins.__dict__:
- del six.moves.builtins.__dict__['_']
+ if '_' in builtins.__dict__:
+ del builtins.__dict__['_']
_gettextutils.install('blaa')
- self.assertIn('_', six.moves.builtins.__dict__)
+ self.assertIn('_', builtins.__dict__)
def test_get_available_languages(self):
# Only the languages available for a specific translation domain
diff --git a/oslo_i18n/tests/test_handler.py b/oslo_i18n/tests/test_handler.py
index ffa9f8e..86dbe8d 100644
--- a/oslo_i18n/tests/test_handler.py
+++ b/oslo_i18n/tests/test_handler.py
@@ -14,11 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import io
import logging
from unittest import mock
from oslotest import base as test_base
-import six
from oslo_i18n import _message
from oslo_i18n import log as i18n_log
@@ -32,7 +32,7 @@ class TranslationHandlerTestCase(test_base.BaseTestCase):
def setUp(self):
super(TranslationHandlerTestCase, self).setUp()
- self.stream = six.StringIO()
+ self.stream = io.StringIO()
self.destination_handler = logging.StreamHandler(self.stream)
self.translation_handler = i18n_log.TranslationHandler('zh_CN')
self.translation_handler.setTarget(self.destination_handler)
diff --git a/oslo_i18n/tests/test_message.py b/oslo_i18n/tests/test_message.py
index f6d7fc6..85dbd67 100644
--- a/oslo_i18n/tests/test_message.py
+++ b/oslo_i18n/tests/test_message.py
@@ -19,7 +19,6 @@ from unittest import mock
import warnings
from oslotest import base as test_base
-import six
import testtools
from oslo_i18n import _message
@@ -42,7 +41,7 @@ class MessageTestCase(test_base.BaseTestCase):
def test_message_is_unicode(self):
message = _message.Message('some %s') % 'message'
- self.assertIsInstance(message, six.text_type)
+ self.assertIsInstance(message, str)
@mock.patch('locale.getdefaultlocale')
@mock.patch('gettext.translation')
@@ -67,7 +66,7 @@ class MessageTestCase(test_base.BaseTestCase):
def test_translation_returns_unicode(self):
message = _message.Message('some %s') % 'message'
- self.assertIsInstance(message.translation(), six.text_type)
+ self.assertIsInstance(message.translation(), str)
def test_mod_with_named_parameters(self):
msgid = ("%(description)s\nCommand: %(cmd)s\n"
@@ -324,7 +323,7 @@ class MessageTestCase(test_base.BaseTestCase):
# Here we are not testing the Message object directly but the result
# of unicoding() an object whose unicode representation is a Message
obj = utils.SomeObject(message)
- unicoded_obj = six.text_type(obj)
+ unicoded_obj = str(obj)
self.assertEqual(es_translation, unicoded_obj.translation('es'))
@@ -491,7 +490,7 @@ class MessageTestCase(test_base.BaseTestCase):
expected_translation = es_translation % param
obj = utils.SomeObject(msg)
- unicoded_obj = six.text_type(obj)
+ unicoded_obj = str(obj)
self.assertEqual(expected_translation, unicoded_obj.translation('es'))
self.assertEqual(default_translation, unicoded_obj.translation('XX'))
diff --git a/oslo_i18n/tests/test_public_api.py b/oslo_i18n/tests/test_public_api.py
index c08384a..bf7a89a 100644
--- a/oslo_i18n/tests/test_public_api.py
+++ b/oslo_i18n/tests/test_public_api.py
@@ -12,7 +12,6 @@
"""A few tests that use the public API to ensure the imports work."""
import unittest
-from unittest import mock
import oslo_i18n
from oslo_i18n import _lazy
@@ -24,8 +23,7 @@ class PublicAPITest(unittest.TestCase):
oslo_i18n.TranslatorFactory('domain')
def test_install(self):
- with mock.patch('six.moves.builtins'):
- oslo_i18n.install('domain')
+ oslo_i18n.install('domain')
def test_get_available_languages(self):
oslo_i18n.get_available_languages('domains')
diff --git a/requirements.txt b/requirements.txt
index a072ac0..6de9f4e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,4 +3,3 @@
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
-six>=1.10.0 # MIT
diff --git a/tox.ini b/tox.ini
index 5440778..9b66168 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,7 +6,7 @@ ignore_basepython_conflict = true
[testenv]
basepython = python3
deps =
- -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands = stestr run --slowest {posargs}
@@ -62,14 +62,8 @@ import_exceptions =
whitelist_externals =
rm
deps =
- -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
+ -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
commands =
rm -rf releasenotes/build
sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html
-
-[testenv:lower-constraints]
-deps =
- -c{toxinidir}/lower-constraints.txt
- -r{toxinidir}/test-requirements.txt
- -r{toxinidir}/requirements.txt