Skip to content

Commit 16add24

Browse files
committed
drop python2 support
1 parent 753f851 commit 16add24

11 files changed

+10
-37
lines changed

README.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MediaWiki OAuth Library
33

44
``mwoauth`` is an open licensed (MIT) library designed to provide a simple means to performing an OAuth handshake with a MediaWiki installation with the `OAuth Extension <https://www.mediawiki.org/wiki/Extension:OAuth>`_ installed.
55

6-
**Compatible with python 2.7 and 3.x**
6+
**Compatible with python 3.x**
77

88
**Install with pip:** ``pip install mwoauth``
99

@@ -15,7 +15,6 @@ Usage
1515
.. code-block:: python
1616
1717
from mwoauth import ConsumerToken, Handshaker
18-
from six.moves import input # For compatibility between python 2 and 3
1918
2019
# Construct a "consumer" from the key/secret provided by MediaWiki
2120
import config

examples/functions.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from mwoauth import ConsumerToken, complete, identify, initiate
55

6-
from six.moves import input # For compatibility between python 2 and 3
7-
86
sys.path.insert(0, ".")
97

108
try:

examples/handshaker.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from mwoauth import ConsumerToken, Handshaker
55

6-
from six.moves import input # For compatibility between python 2 and 3
7-
86
try:
97
creds_doc = json.load(open("credentials.do_not_commit.json"))
108
consumer_key = creds_doc['consumer_key']

examples/request-oauthlib.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from mwoauth import ConsumerToken, Handshaker
55
from requests_oauthlib import OAuth1
66

7-
from six.moves import input # For compatibility between python 2 and 3
8-
97
try:
108
creds_doc = json.load(open("credentials.do_not_commit.json"))
119
consumer_key = creds_doc['consumer_key']

mwoauth/flask.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
import logging
1010
from functools import wraps
11+
from urllib.parse import urljoin
1112

1213
import flask
1314
from requests_oauthlib import OAuth1
1415

15-
from six.moves.urllib.parse import urljoin
16-
1716
from .errors import OAuthException
1817
from .handshaker import Handshaker
1918
from .tokens import AccessToken, RequestToken

mwoauth/functions.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
.. code-block:: python
77
88
from mwoauth import ConsumerToken, initiate, complete, identify
9-
from six.moves import input # For compatibility between python 2 and 3
109
1110
# Consruct a "consumer" from the key/secret provided by MediaWiki
1211
import config
@@ -35,27 +34,22 @@
3534
import json
3635
import re
3736
import time
37+
from urllib.parse import parse_qs, urlencode, urlparse
3838

3939
import jwt
4040
import requests
4141
from requests_oauthlib import OAuth1
42-
from six import PY3, text_type
43-
44-
from six.moves.urllib.parse import parse_qs, urlencode, urlparse
4542

4643
from . import defaults
4744
from .errors import OAuthException
4845
from .tokens import AccessToken, RequestToken
4946

5047

5148
def force_unicode(val, encoding="unicode-escape"):
52-
if type(val) == text_type:
49+
if type(val) == str:
5350
return val
5451
else:
55-
if PY3:
56-
return val.decode(encoding, errors="replace")
57-
else:
58-
return unicode(val, encoding, errors="replace") # noqa
52+
return val.decode(encoding, errors="replace")
5953

6054

6155
def initiate(mw_uri, consumer_token, callback='oob',

mwoauth/handshaker.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
.. code-block:: python
66
77
from mwoauth import ConsumerToken, Handshaker
8-
from six.moves import input # For compatibility between python 2 and 3
98
109
# Consruct a "consumer" from the key/secret provided by MediaWiki
1110
import config

mwoauth/tests/test_functions.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
# -*- coding: UTF-8 -*-
22
import pytest
3-
from six import PY3, b
43

54
from ..errors import OAuthException
65
from ..functions import process_request_token
76

87

98
def test_process_request_token():
109
request_token = process_request_token(
11-
b("oauth_token=iamatoken&oauth_token_secret=iamasecret"))
10+
b"oauth_token=iamatoken&oauth_token_secret=iamasecret")
1211
assert request_token.key == "iamatoken"
1312
assert request_token.secret == "iamasecret"
1413

1514

1615
def test_process_request_token_errors():
17-
if PY3:
18-
text = "Error: Произошла ошибка в протоколе OAuth: " + \
19-
"Invalid consumer key"
20-
content = bytes(text, "utf-8")
21-
else:
22-
content = "Error: Произошла ошибка в протоколе OAuth: " + \
23-
"Invalid consumer key"
24-
text = unicode(content, "utf-8")
16+
text = "Error: Произошла ошибка в протоколе OAuth: " + \
17+
"Invalid consumer key"
18+
content = bytes(text, "utf-8")
2519
with pytest.raises(OAuthException, match=text[len("Error: "):]):
2620
process_request_token(content)
2721

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
PyJWT == 2.4.0
22
requests == 2.21.0
33
requests-oauthlib == 1.2.0
4-
six == 1.12.0

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def read(fname):
2626
'oauthlib',
2727
'requests',
2828
'requests-oauthlib',
29-
'six'
3029
],
3130
extras_require={
3231
'flask': ['flask'],

tox.ini

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py35, flake8, doc
2+
envlist = py35, flake8, doc
33
minversion = 1.6
44
skipsdist = True
55

@@ -8,9 +8,6 @@ deps = -r{toxinidir}/requirements.txt
88
flask
99
commands=python setup.py test
1010

11-
[testenv:py27]
12-
basepython = python2.7
13-
1411
[testenv:py35]
1512
basepython = python3.5
1613

@@ -25,5 +22,4 @@ commands = flake8 {posargs}
2522
deps = flake8
2623

2724
[tox:travis]
28-
2.7 = py27, flake8
2925
3.5 = py35, flake8, doc

0 commit comments

Comments
 (0)