From 3f78aa3c0d3fc502f295986d4951cfd0eee80786 Mon Sep 17 00:00:00 2001 From: Max Wittig Date: Wed, 18 Dec 2019 12:13:08 +0100 Subject: [PATCH 1/5] chore: bump minimum required requests version for security reasons --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9c3f4d65b..ae7524b6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -requests>=2.4.2 +requests>=2.22.0 six diff --git a/setup.py b/setup.py index 6f52eccf3..fbf834f93 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def get_version(): license="LGPLv3", url="https://github.com/python-gitlab/python-gitlab", packages=find_packages(), - install_requires=["requests>=2.4.2", "six"], + install_requires=["requests>=2.22.0", "six"], entry_points={"console_scripts": ["gitlab = gitlab.cli:main"]}, classifiers=[ "Development Status :: 5 - Production/Stable", From 7ecd5184e62bf1b1f377db161b26fa4580af6b4c Mon Sep 17 00:00:00 2001 From: Max Wittig Date: Wed, 18 Dec 2019 12:14:28 +0100 Subject: [PATCH 2/5] chore: add PyYaml as extra require --- docs/cli.rst | 2 +- setup.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/cli.rst b/docs/cli.rst index e87c6d104..320790203 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -162,7 +162,7 @@ These options must be defined before the mandatory arguments. **Notice:** The `PyYAML package `_ is required to use the yaml output option. - You need to install it separately using ``pip install PyYAML`` + You need to install it explicitly using ``pip install python-gitlab[yaml]`` ``--fields``, ``-f`` Comma-separated list of fields to display (``yaml`` and ``json`` output diff --git a/setup.py b/setup.py index fbf834f93..2eb7009d8 100644 --- a/setup.py +++ b/setup.py @@ -45,5 +45,8 @@ def get_version(): "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", ], - extras_require={"autocompletion": ["argcomplete>=1.10.0,<2"]}, + extras_require={ + "autocompletion": ["argcomplete>=1.10.0,<2"], + "yaml": ["PyYaml>=5.2"], + }, ) From af8679ac5c2c2b7774d624bdb1981d0e2374edc1 Mon Sep 17 00:00:00 2001 From: Max Wittig Date: Wed, 18 Dec 2019 12:24:36 +0100 Subject: [PATCH 3/5] chore: drop legacy python tests Support dropped for: 2.7, 3.4, 3.5 --- .travis.yml | 28 +++++----------------------- Dockerfile | 4 ++-- setup.py | 4 ---- tox.ini | 2 +- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index b631f21d5..83d2d3391 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,49 +21,31 @@ jobs: - stage: lint name: black_lint dist: bionic - python: 3.7 + python: 3.8 script: - pip3 install -U --pre black - black --check . - stage: test name: cli_func_v4 dist: bionic - python: 3.7 + python: 3.8 script: - pip3 install tox - tox -e cli_func_v4 - stage: test name: py_func_v4 dist: bionic - python: 3.7 + python: 3.8 script: - pip3 install tox - tox -e py_func_v4 - stage: test name: docs dist: bionic - python: 3.7 + python: 3.8 script: - pip3 install tox - tox -e docs - - stage: test - name: py27 - python: 2.7 - script: - - pip2 install tox - - tox -e py27 - - stage: test - name: py34 - python: 3.4 - script: - - pip3 install tox - - tox -e py34 - - stage: test - name: py35 - python: 3.5 - script: - - pip3 install tox - - tox -e py35 - stage: test name: py36 python: 3.6 @@ -81,7 +63,7 @@ jobs: - stage: test dist: bionic name: py38 - python: 3.8-dev + python: 3.8 script: - pip3 install tox - tox -e py38 diff --git a/Dockerfile b/Dockerfile index 489a4207a..1eb7f8bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM python:3.7-alpine AS build +FROM python:3.8-alpine AS build WORKDIR /opt/python-gitlab COPY . . RUN python setup.py bdist_wheel -FROM python:3.7-alpine +FROM python:3.8-alpine WORKDIR /opt/python-gitlab COPY --from=build /opt/python-gitlab/dist dist/ diff --git a/setup.py b/setup.py index 2eb7009d8..a363261d4 100644 --- a/setup.py +++ b/setup.py @@ -36,11 +36,7 @@ def get_version(): "Operating System :: POSIX", "Operating System :: Microsoft :: Windows", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/tox.ini b/tox.ini index db28f6ea8..0aa43f09e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] minversion = 1.6 skipsdist = True -envlist = py38,py37,py36,py35,py34,py27,pep8,black +envlist = py38,py37,py36,pep8,black [testenv] setenv = VIRTUAL_ENV={envdir} From 9fb46454c6dab1a86ab4492df2368ed74badf7d6 Mon Sep 17 00:00:00 2001 From: Max Wittig Date: Wed, 18 Dec 2019 13:14:54 +0100 Subject: [PATCH 4/5] refactor: remove six dependency --- README.rst | 1 - docs/ext/docstrings.py | 3 +-- gitlab/__init__.py | 5 ++--- gitlab/config.py | 3 +-- gitlab/tests/test_cli.py | 7 +++---- gitlab/tests/test_config.py | 22 +++++++++++----------- gitlab/utils.py | 4 ++-- gitlab/v4/cli.py | 6 ++---- requirements.txt | 1 - setup.py | 2 +- tools/generate_token.py | 2 +- 11 files changed, 24 insertions(+), 32 deletions(-) diff --git a/README.rst b/README.rst index bb87081e6..3802bcbc1 100644 --- a/README.rst +++ b/README.rst @@ -32,7 +32,6 @@ Requirements python-gitlab depends on: * `python-requests `_ -* `six `_ Install with pip ---------------- diff --git a/docs/ext/docstrings.py b/docs/ext/docstrings.py index e42bb606d..754da271d 100644 --- a/docs/ext/docstrings.py +++ b/docs/ext/docstrings.py @@ -3,7 +3,6 @@ import os import jinja2 -import six import sphinx import sphinx.ext.napoleon as napoleon from sphinx.ext.napoleon.docstring import GoogleDocstring @@ -25,7 +24,7 @@ def setup(app): conf = napoleon.Config._config_values - for name, (default, rebuild) in six.iteritems(conf): + for name, (default, rebuild) in conf.items(): app.add_config_value(name, default, rebuild) return {"version": sphinx.__display_version__, "parallel_read_safe": True} diff --git a/gitlab/__init__.py b/gitlab/__init__.py index be9e01fb1..282413142 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -23,7 +23,6 @@ import warnings import requests -import six import gitlab.config from gitlab.const import * # noqa @@ -47,8 +46,8 @@ def _sanitize(value): if isinstance(value, dict): - return dict((k, _sanitize(v)) for k, v in six.iteritems(value)) - if isinstance(value, six.string_types): + return dict((k, _sanitize(v)) for k, v in value.items()) + if isinstance(value, str): return value.replace("/", "%2F") return value diff --git a/gitlab/config.py b/gitlab/config.py index 4b4d6fdec..b2c0dbf84 100644 --- a/gitlab/config.py +++ b/gitlab/config.py @@ -16,8 +16,7 @@ # along with this program. If not, see . import os - -from six.moves import configparser +import configparser _DEFAULT_FILES = ["/etc/python-gitlab.cfg", os.path.expanduser("~/.python-gitlab.cfg")] diff --git a/gitlab/tests/test_cli.py b/gitlab/tests/test_cli.py index 04a196115..48201036f 100644 --- a/gitlab/tests/test_cli.py +++ b/gitlab/tests/test_cli.py @@ -20,6 +20,7 @@ import os import tempfile import unittest +import io try: from contextlib import redirect_stderr # noqa: H302 @@ -34,8 +35,6 @@ def redirect_stderr(new_target): sys.stderr = old_target -import six - from gitlab import cli import gitlab.v4.cli @@ -56,7 +55,7 @@ class TestClass(object): self.assertEqual("class", cli.cls_to_what(Class)) def test_die(self): - fl = six.StringIO() + fl = io.StringIO() with redirect_stderr(fl): with self.assertRaises(SystemExit) as test: cli.die("foobar") @@ -83,7 +82,7 @@ def test_parse_value(self): self.assertEqual(ret, "content") os.unlink(temp_path) - fl = six.StringIO() + fl = io.StringIO() with redirect_stderr(fl): with self.assertRaises(SystemExit) as exc: cli._parse_value("@/thisfileprobablydoesntexist") diff --git a/gitlab/tests/test_config.py b/gitlab/tests/test_config.py index a43f97758..65bd30053 100644 --- a/gitlab/tests/test_config.py +++ b/gitlab/tests/test_config.py @@ -18,7 +18,7 @@ import unittest import mock -import six +import io from gitlab import config @@ -80,16 +80,16 @@ def test_missing_config(self, path_exists): config.GitlabConfigParser("test") @mock.patch("os.path.exists") - @mock.patch("six.moves.builtins.open") + @mock.patch("builtins.open") def test_invalid_id(self, m_open, path_exists): - fd = six.StringIO(no_default_config) + fd = io.StringIO(no_default_config) fd.close = mock.Mock(return_value=None) m_open.return_value = fd path_exists.return_value = True config.GitlabConfigParser("there") self.assertRaises(config.GitlabIDError, config.GitlabConfigParser) - fd = six.StringIO(valid_config) + fd = io.StringIO(valid_config) fd.close = mock.Mock(return_value=None) m_open.return_value = fd self.assertRaises( @@ -97,9 +97,9 @@ def test_invalid_id(self, m_open, path_exists): ) @mock.patch("os.path.exists") - @mock.patch("six.moves.builtins.open") + @mock.patch("builtins.open") def test_invalid_data(self, m_open, path_exists): - fd = six.StringIO(missing_attr_config) + fd = io.StringIO(missing_attr_config) fd.close = mock.Mock(return_value=None, side_effect=lambda: fd.seek(0)) m_open.return_value = fd path_exists.return_value = True @@ -117,9 +117,9 @@ def test_invalid_data(self, m_open, path_exists): self.assertEqual("Unsupported per_page number: 200", emgr.exception.args[0]) @mock.patch("os.path.exists") - @mock.patch("six.moves.builtins.open") + @mock.patch("builtins.open") def test_valid_data(self, m_open, path_exists): - fd = six.StringIO(valid_config) + fd = io.StringIO(valid_config) fd.close = mock.Mock(return_value=None) m_open.return_value = fd path_exists.return_value = True @@ -133,7 +133,7 @@ def test_valid_data(self, m_open, path_exists): self.assertEqual(True, cp.ssl_verify) self.assertIsNone(cp.per_page) - fd = six.StringIO(valid_config) + fd = io.StringIO(valid_config) fd.close = mock.Mock(return_value=None) m_open.return_value = fd cp = config.GitlabConfigParser(gitlab_id="two") @@ -144,7 +144,7 @@ def test_valid_data(self, m_open, path_exists): self.assertEqual(10, cp.timeout) self.assertEqual(False, cp.ssl_verify) - fd = six.StringIO(valid_config) + fd = io.StringIO(valid_config) fd.close = mock.Mock(return_value=None) m_open.return_value = fd cp = config.GitlabConfigParser(gitlab_id="three") @@ -156,7 +156,7 @@ def test_valid_data(self, m_open, path_exists): self.assertEqual("/path/to/CA/bundle.crt", cp.ssl_verify) self.assertEqual(50, cp.per_page) - fd = six.StringIO(valid_config) + fd = io.StringIO(valid_config) fd.close = mock.Mock(return_value=None) m_open.return_value = fd cp = config.GitlabConfigParser(gitlab_id="four") diff --git a/gitlab/utils.py b/gitlab/utils.py index 94528e1e1..0992ed781 100644 --- a/gitlab/utils.py +++ b/gitlab/utils.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . -import six +from urllib.parse import urlparse class _StdoutStream(object): @@ -52,6 +52,6 @@ def clean_str_id(id): def sanitized_url(url): - parsed = six.moves.urllib.parse.urlparse(url) + parsed = urlparse(url) new_path = parsed.path.replace(".", "%2E") return parsed._replace(path=new_path).geturl() diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 6fc41aca2..a8752612e 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -21,8 +21,6 @@ import operator import sys -import six - import gitlab import gitlab.base from gitlab import cli @@ -321,7 +319,7 @@ def extend_parser(parser): def get_dict(obj, fields): - if isinstance(obj, six.string_types): + if isinstance(obj, str): return obj if fields: @@ -441,7 +439,7 @@ def run(gl, what, action, args, verbose, output, fields): printer.display_list(data, fields, verbose=verbose) elif isinstance(data, gitlab.base.RESTObject): printer.display(get_dict(data, fields), verbose=verbose, obj=data) - elif isinstance(data, six.string_types): + elif isinstance(data, str): print(data) elif hasattr(data, "decode"): print(data.decode()) diff --git a/requirements.txt b/requirements.txt index ae7524b6e..d5c2bc9c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ requests>=2.22.0 -six diff --git a/setup.py b/setup.py index a363261d4..da02f9fb4 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def get_version(): license="LGPLv3", url="https://github.com/python-gitlab/python-gitlab", packages=find_packages(), - install_requires=["requests>=2.22.0", "six"], + install_requires=["requests>=2.22.0"], entry_points={"console_scripts": ["gitlab = gitlab.cli:main"]}, classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/tools/generate_token.py b/tools/generate_token.py index 10ca8915e..89909bd90 100755 --- a/tools/generate_token.py +++ b/tools/generate_token.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from six.moves.urllib.parse import urljoin +from urllib.parse import urljoin from requests_html import HTMLSession ENDPOINT = "http://localhost:8080" From c817dccde8c104dcb294bbf1590c7e3ae9539466 Mon Sep 17 00:00:00 2001 From: Max Wittig Date: Wed, 18 Dec 2019 13:57:05 +0100 Subject: [PATCH 5/5] chore: bump to 2.0.0 Dropping support for legacy python requires a new major version --- gitlab/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 282413142..b37702319 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -30,7 +30,7 @@ from gitlab import utils # noqa __title__ = "python-gitlab" -__version__ = "1.15.0" +__version__ = "2.0.0" __author__ = "Gauvain Pocentek" __email__ = "gauvainpocentek@gmail.com" __license__ = "LGPL3"