Skip to content

Commit 5fa0e16

Browse files
Merge pull request #980 from python-gitlab/refactor/cleanup-upgrade
Refactor/cleanup upgrade
2 parents 5a10eb3 + c817dcc commit 5fa0e16

File tree

15 files changed

+39
-66
lines changed

15 files changed

+39
-66
lines changed

.travis.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,31 @@ jobs:
2121
- stage: lint
2222
name: black_lint
2323
dist: bionic
24-
python: 3.7
24+
python: 3.8
2525
script:
2626
- pip3 install -U --pre black
2727
- black --check .
2828
- stage: test
2929
name: cli_func_v4
3030
dist: bionic
31-
python: 3.7
31+
python: 3.8
3232
script:
3333
- pip3 install tox
3434
- tox -e cli_func_v4
3535
- stage: test
3636
name: py_func_v4
3737
dist: bionic
38-
python: 3.7
38+
python: 3.8
3939
script:
4040
- pip3 install tox
4141
- tox -e py_func_v4
4242
- stage: test
4343
name: docs
4444
dist: bionic
45-
python: 3.7
45+
python: 3.8
4646
script:
4747
- pip3 install tox
4848
- tox -e docs
49-
- stage: test
50-
name: py27
51-
python: 2.7
52-
script:
53-
- pip2 install tox
54-
- tox -e py27
55-
- stage: test
56-
name: py34
57-
python: 3.4
58-
script:
59-
- pip3 install tox
60-
- tox -e py34
61-
- stage: test
62-
name: py35
63-
python: 3.5
64-
script:
65-
- pip3 install tox
66-
- tox -e py35
6749
- stage: test
6850
name: py36
6951
python: 3.6
@@ -81,7 +63,7 @@ jobs:
8163
- stage: test
8264
dist: bionic
8365
name: py38
84-
python: 3.8-dev
66+
python: 3.8
8567
script:
8668
- pip3 install tox
8769
- tox -e py38

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM python:3.7-alpine AS build
1+
FROM python:3.8-alpine AS build
22

33
WORKDIR /opt/python-gitlab
44
COPY . .
55
RUN python setup.py bdist_wheel
66

7-
FROM python:3.7-alpine
7+
FROM python:3.8-alpine
88

99
WORKDIR /opt/python-gitlab
1010
COPY --from=build /opt/python-gitlab/dist dist/

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Requirements
3232
python-gitlab depends on:
3333

3434
* `python-requests <http://docs.python-requests.org/en/latest/>`_
35-
* `six <https://six.readthedocs.io/>`_
3635

3736
Install with pip
3837
----------------

docs/cli.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ These options must be defined before the mandatory arguments.
162162
**Notice:**
163163

164164
The `PyYAML package <https://pypi.org/project/PyYAML/>`_ is required to use the yaml output option.
165-
You need to install it separately using ``pip install PyYAML``
165+
You need to install it explicitly using ``pip install python-gitlab[yaml]``
166166

167167
``--fields``, ``-f``
168168
Comma-separated list of fields to display (``yaml`` and ``json`` output

docs/ext/docstrings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44

55
import jinja2
6-
import six
76
import sphinx
87
import sphinx.ext.napoleon as napoleon
98
from sphinx.ext.napoleon.docstring import GoogleDocstring
@@ -25,7 +24,7 @@ def setup(app):
2524

2625
conf = napoleon.Config._config_values
2726

28-
for name, (default, rebuild) in six.iteritems(conf):
27+
for name, (default, rebuild) in conf.items():
2928
app.add_config_value(name, default, rebuild)
3029
return {"version": sphinx.__display_version__, "parallel_read_safe": True}
3130

gitlab/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323
import warnings
2424

2525
import requests
26-
import six
2726

2827
import gitlab.config
2928
from gitlab.const import * # noqa
3029
from gitlab.exceptions import * # noqa
3130
from gitlab import utils # noqa
3231

3332
__title__ = "python-gitlab"
34-
__version__ = "1.15.0"
33+
__version__ = "2.0.0"
3534
__author__ = "Gauvain Pocentek"
3635
__email__ = "gauvainpocentek@gmail.com"
3736
__license__ = "LGPL3"
@@ -47,8 +46,8 @@
4746

4847
def _sanitize(value):
4948
if isinstance(value, dict):
50-
return dict((k, _sanitize(v)) for k, v in six.iteritems(value))
51-
if isinstance(value, six.string_types):
49+
return dict((k, _sanitize(v)) for k, v in value.items())
50+
if isinstance(value, str):
5251
return value.replace("/", "%2F")
5352
return value
5453

gitlab/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import os
19-
20-
from six.moves import configparser
19+
import configparser
2120

2221
_DEFAULT_FILES = ["/etc/python-gitlab.cfg", os.path.expanduser("~/.python-gitlab.cfg")]
2322

gitlab/tests/test_cli.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import os
2121
import tempfile
2222
import unittest
23+
import io
2324

2425
try:
2526
from contextlib import redirect_stderr # noqa: H302
@@ -34,8 +35,6 @@ def redirect_stderr(new_target):
3435
sys.stderr = old_target
3536

3637

37-
import six
38-
3938
from gitlab import cli
4039
import gitlab.v4.cli
4140

@@ -56,7 +55,7 @@ class TestClass(object):
5655
self.assertEqual("class", cli.cls_to_what(Class))
5756

5857
def test_die(self):
59-
fl = six.StringIO()
58+
fl = io.StringIO()
6059
with redirect_stderr(fl):
6160
with self.assertRaises(SystemExit) as test:
6261
cli.die("foobar")
@@ -83,7 +82,7 @@ def test_parse_value(self):
8382
self.assertEqual(ret, "content")
8483
os.unlink(temp_path)
8584

86-
fl = six.StringIO()
85+
fl = io.StringIO()
8786
with redirect_stderr(fl):
8887
with self.assertRaises(SystemExit) as exc:
8988
cli._parse_value("@/thisfileprobablydoesntexist")

gitlab/tests/test_config.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import unittest
1919

2020
import mock
21-
import six
21+
import io
2222

2323
from gitlab import config
2424

@@ -80,26 +80,26 @@ def test_missing_config(self, path_exists):
8080
config.GitlabConfigParser("test")
8181

8282
@mock.patch("os.path.exists")
83-
@mock.patch("six.moves.builtins.open")
83+
@mock.patch("builtins.open")
8484
def test_invalid_id(self, m_open, path_exists):
85-
fd = six.StringIO(no_default_config)
85+
fd = io.StringIO(no_default_config)
8686
fd.close = mock.Mock(return_value=None)
8787
m_open.return_value = fd
8888
path_exists.return_value = True
8989
config.GitlabConfigParser("there")
9090
self.assertRaises(config.GitlabIDError, config.GitlabConfigParser)
9191

92-
fd = six.StringIO(valid_config)
92+
fd = io.StringIO(valid_config)
9393
fd.close = mock.Mock(return_value=None)
9494
m_open.return_value = fd
9595
self.assertRaises(
9696
config.GitlabDataError, config.GitlabConfigParser, gitlab_id="not_there"
9797
)
9898

9999
@mock.patch("os.path.exists")
100-
@mock.patch("six.moves.builtins.open")
100+
@mock.patch("builtins.open")
101101
def test_invalid_data(self, m_open, path_exists):
102-
fd = six.StringIO(missing_attr_config)
102+
fd = io.StringIO(missing_attr_config)
103103
fd.close = mock.Mock(return_value=None, side_effect=lambda: fd.seek(0))
104104
m_open.return_value = fd
105105
path_exists.return_value = True
@@ -117,9 +117,9 @@ def test_invalid_data(self, m_open, path_exists):
117117
self.assertEqual("Unsupported per_page number: 200", emgr.exception.args[0])
118118

119119
@mock.patch("os.path.exists")
120-
@mock.patch("six.moves.builtins.open")
120+
@mock.patch("builtins.open")
121121
def test_valid_data(self, m_open, path_exists):
122-
fd = six.StringIO(valid_config)
122+
fd = io.StringIO(valid_config)
123123
fd.close = mock.Mock(return_value=None)
124124
m_open.return_value = fd
125125
path_exists.return_value = True
@@ -133,7 +133,7 @@ def test_valid_data(self, m_open, path_exists):
133133
self.assertEqual(True, cp.ssl_verify)
134134
self.assertIsNone(cp.per_page)
135135

136-
fd = six.StringIO(valid_config)
136+
fd = io.StringIO(valid_config)
137137
fd.close = mock.Mock(return_value=None)
138138
m_open.return_value = fd
139139
cp = config.GitlabConfigParser(gitlab_id="two")
@@ -144,7 +144,7 @@ def test_valid_data(self, m_open, path_exists):
144144
self.assertEqual(10, cp.timeout)
145145
self.assertEqual(False, cp.ssl_verify)
146146

147-
fd = six.StringIO(valid_config)
147+
fd = io.StringIO(valid_config)
148148
fd.close = mock.Mock(return_value=None)
149149
m_open.return_value = fd
150150
cp = config.GitlabConfigParser(gitlab_id="three")
@@ -156,7 +156,7 @@ def test_valid_data(self, m_open, path_exists):
156156
self.assertEqual("/path/to/CA/bundle.crt", cp.ssl_verify)
157157
self.assertEqual(50, cp.per_page)
158158

159-
fd = six.StringIO(valid_config)
159+
fd = io.StringIO(valid_config)
160160
fd.close = mock.Mock(return_value=None)
161161
m_open.return_value = fd
162162
cp = config.GitlabConfigParser(gitlab_id="four")

gitlab/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
import six
18+
from urllib.parse import urlparse
1919

2020

2121
class _StdoutStream(object):
@@ -52,6 +52,6 @@ def clean_str_id(id):
5252

5353

5454
def sanitized_url(url):
55-
parsed = six.moves.urllib.parse.urlparse(url)
55+
parsed = urlparse(url)
5656
new_path = parsed.path.replace(".", "%2E")
5757
return parsed._replace(path=new_path).geturl()

gitlab/v4/cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import operator
2222
import sys
2323

24-
import six
25-
2624
import gitlab
2725
import gitlab.base
2826
from gitlab import cli
@@ -321,7 +319,7 @@ def extend_parser(parser):
321319

322320

323321
def get_dict(obj, fields):
324-
if isinstance(obj, six.string_types):
322+
if isinstance(obj, str):
325323
return obj
326324

327325
if fields:
@@ -441,7 +439,7 @@ def run(gl, what, action, args, verbose, output, fields):
441439
printer.display_list(data, fields, verbose=verbose)
442440
elif isinstance(data, gitlab.base.RESTObject):
443441
printer.display(get_dict(data, fields), verbose=verbose, obj=data)
444-
elif isinstance(data, six.string_types):
442+
elif isinstance(data, str):
445443
print(data)
446444
elif hasattr(data, "decode"):
447445
print(data.decode())

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
requests>=2.4.2
2-
six
1+
requests>=2.22.0

setup.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_version():
2525
license="LGPLv3",
2626
url="https://github.com/python-gitlab/python-gitlab",
2727
packages=find_packages(),
28-
install_requires=["requests>=2.4.2", "six"],
28+
install_requires=["requests>=2.22.0"],
2929
entry_points={"console_scripts": ["gitlab = gitlab.cli:main"]},
3030
classifiers=[
3131
"Development Status :: 5 - Production/Stable",
@@ -36,14 +36,13 @@ def get_version():
3636
"Operating System :: POSIX",
3737
"Operating System :: Microsoft :: Windows",
3838
"Programming Language :: Python",
39-
"Programming Language :: Python :: 2",
40-
"Programming Language :: Python :: 2.7",
4139
"Programming Language :: Python :: 3",
42-
"Programming Language :: Python :: 3.4",
43-
"Programming Language :: Python :: 3.5",
4440
"Programming Language :: Python :: 3.6",
4541
"Programming Language :: Python :: 3.7",
4642
"Programming Language :: Python :: 3.8",
4743
],
48-
extras_require={"autocompletion": ["argcomplete>=1.10.0,<2"]},
44+
extras_require={
45+
"autocompletion": ["argcomplete>=1.10.0,<2"],
46+
"yaml": ["PyYaml>=5.2"],
47+
},
4948
)

tools/generate_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from six.moves.urllib.parse import urljoin
3+
from urllib.parse import urljoin
44
from requests_html import HTMLSession
55

66
ENDPOINT = "http://localhost:8080"

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
minversion = 1.6
33
skipsdist = True
4-
envlist = py38,py37,py36,py35,py34,py27,pep8,black
4+
envlist = py38,py37,py36,pep8,black
55

66
[testenv]
77
setenv = VIRTUAL_ENV={envdir}

0 commit comments

Comments
 (0)