Remove Python 2 warnings, apply lint updates
This commit is contained in:
parent
7383fa20cf
commit
109315d93d
|
@ -3,6 +3,7 @@ repos:
|
||||||
rev: v1.24.0
|
rev: v1.24.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
|
args: ["--py3-plus"]
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 19.3b0
|
rev: 19.3b0
|
||||||
|
|
27
setup.py
27
setup.py
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import sys
|
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
version_dict = {}
|
version_dict = {}
|
||||||
|
@ -9,31 +7,6 @@ with open("src/pylast/version.py") as f:
|
||||||
version = version_dict["__version__"]
|
version = version_dict["__version__"]
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info < (3, 5):
|
|
||||||
error = """pylast 3.0 and above are no longer compatible with Python 2.
|
|
||||||
|
|
||||||
This is pylast {} and you are using Python {}.
|
|
||||||
Make sure you have pip >= 9.0 and setuptools >= 24.2 and retry:
|
|
||||||
|
|
||||||
$ pip install --upgrade pip setuptools
|
|
||||||
|
|
||||||
Other choices:
|
|
||||||
|
|
||||||
- Upgrade to Python 3.
|
|
||||||
|
|
||||||
- Install an older version of pylast:
|
|
||||||
|
|
||||||
$ pip install 'pylast<3.0'
|
|
||||||
|
|
||||||
For more information:
|
|
||||||
|
|
||||||
https://github.com/pylast/pylast/issues/265
|
|
||||||
""".format(
|
|
||||||
version, ".".join([str(v) for v in sys.version_info[:3]])
|
|
||||||
)
|
|
||||||
print(error, file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
with open("README.md") as f:
|
with open("README.md") as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# pylast -
|
# pylast -
|
||||||
# A Python interface to Last.fm and Libre.fm
|
# A Python interface to Last.fm and Libre.fm
|
||||||
|
@ -26,12 +25,12 @@ import html.entities
|
||||||
import logging
|
import logging
|
||||||
import shelve
|
import shelve
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import warnings
|
import warnings
|
||||||
import xml.dom
|
import xml.dom
|
||||||
from http.client import HTTPSConnection
|
from http.client import HTTPSConnection
|
||||||
|
from urllib.parse import quote_plus
|
||||||
from xml.dom import Node, minidom
|
from xml.dom import Node, minidom
|
||||||
|
|
||||||
from . import version
|
from . import version
|
||||||
|
@ -44,34 +43,6 @@ __license__ = "apache2"
|
||||||
__email__ = "amr.hassan@gmail.com"
|
__email__ = "amr.hassan@gmail.com"
|
||||||
__version__ = version.__version__
|
__version__ = version.__version__
|
||||||
|
|
||||||
if sys.version_info < (3,):
|
|
||||||
raise ImportError(
|
|
||||||
"""pylast 3.0 and above are no longer compatible with Python 2.
|
|
||||||
|
|
||||||
This is pylast {} and you are using Python {}.
|
|
||||||
Make sure you have pip >= 9.0 and setuptools >= 24.2 and retry:
|
|
||||||
|
|
||||||
$ pip install --upgrade pip setuptools
|
|
||||||
|
|
||||||
Other choices:
|
|
||||||
|
|
||||||
- Upgrade to Python 3.
|
|
||||||
|
|
||||||
- Install an older version of pylast:
|
|
||||||
|
|
||||||
$ pip install 'pylast<3.0'
|
|
||||||
|
|
||||||
For more information:
|
|
||||||
|
|
||||||
https://github.com/pylast/pylast/issues/265
|
|
||||||
""".format(
|
|
||||||
version, ".".join([str(v) for v in sys.version_info[:3]])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# Keep importable on Python 2 for a while to show ImportError
|
|
||||||
from urllib.parse import quote_plus as url_quote_plus
|
|
||||||
|
|
||||||
|
|
||||||
# 1 : This error does not exist
|
# 1 : This error does not exist
|
||||||
STATUS_INVALID_SERVICE = 2
|
STATUS_INVALID_SERVICE = 2
|
||||||
|
@ -896,7 +867,7 @@ class _Request:
|
||||||
keys = list(self.params.keys())
|
keys = list(self.params.keys())
|
||||||
keys.sort()
|
keys.sort()
|
||||||
|
|
||||||
cache_key = str()
|
cache_key = ""
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key != "api_sig" and key != "api_key" and key != "sk":
|
if key != "api_sig" and key != "api_key" and key != "sk":
|
||||||
|
@ -926,7 +897,7 @@ class _Request:
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for name in self.params.keys():
|
for name in self.params.keys():
|
||||||
data.append("=".join((name, url_quote_plus(_string(self.params[name])))))
|
data.append("=".join((name, quote_plus(_string(self.params[name])))))
|
||||||
data = "&".join(data)
|
data = "&".join(data)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -2932,7 +2903,7 @@ def _extract_tracks(doc, network):
|
||||||
def _url_safe(text):
|
def _url_safe(text):
|
||||||
"""Does all kinds of tricks on a text to make it safe to use in a URL."""
|
"""Does all kinds of tricks on a text to make it safe to use in a URL."""
|
||||||
|
|
||||||
return url_quote_plus(url_quote_plus(_string(text))).lower()
|
return quote_plus(quote_plus(_string(text))).lower()
|
||||||
|
|
||||||
|
|
||||||
def _number(string):
|
def _number(string):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import mock
|
import mock
|
||||||
import pylast
|
import pylast
|
||||||
import pytest
|
import pytest
|
||||||
|
|
Loading…
Reference in a new issue