From 905d06ef5d942e30d6f5587085f5461e97e8ae32 Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 27 Jul 2018 15:35:38 +0300 Subject: [PATCH 1/3] Upgrade Python syntax with pyupgrade --- pylast/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 0b9755b..d5622c2 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1018,11 +1018,11 @@ class SessionKeyGenerator(object): token = self._get_web_auth_token() - url = "%(homepage)s/api/auth/?api_key=%(api)s&token=%(token)s" % { - "homepage": self.network.homepage, - "api": self.network.api_key, - "token": token, - } + url = "{homepage}/api/auth/?api_key={api}&token={token}".format( + homepage=self.network.homepage, + api=self.network.api_key, + token=token, + ) self.web_auth_tokens[url] = token From c1e70f798c4ff3ceb5c5aff31e9d0c448eff8665 Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 27 Jul 2018 15:36:59 +0300 Subject: [PATCH 2/3] UserWarning when importing on Python <3 https://python3statement.org/practicalities/#runtime-warning-on-master --- pylast/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pylast/__init__.py b/pylast/__init__.py index d5622c2..3061d3d 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -30,6 +30,7 @@ import ssl import sys import tempfile import time +import warnings import xml.dom from . import version @@ -42,6 +43,12 @@ __license__ = "apache2" __email__ = "amr.hassan@gmail.com" __version__ = version.__version__ +if sys.version_info < (3,): + warnings.warn('You are using pylast with Python 2. ' + 'Pylast will soon be Python 3 only. ' + 'More info: https://github.com/pylast/pylast/issues/265', + UserWarning) + if sys.version_info.major == 2: import htmlentitydefs from httplib import HTTPSConnection From be52e1793ae4b451e44a3967959acc6c07c53023 Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 27 Jul 2018 16:02:00 +0300 Subject: [PATCH 3/3] Black fix --- pylast/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 3061d3d..b2ffa37 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -44,10 +44,12 @@ __email__ = "amr.hassan@gmail.com" __version__ = version.__version__ if sys.version_info < (3,): - warnings.warn('You are using pylast with Python 2. ' - 'Pylast will soon be Python 3 only. ' - 'More info: https://github.com/pylast/pylast/issues/265', - UserWarning) + warnings.warn( + "You are using pylast with Python 2. " + "Pylast will soon be Python 3 only. " + "More info: https://github.com/pylast/pylast/issues/265", + UserWarning, + ) if sys.version_info.major == 2: import htmlentitydefs @@ -1026,9 +1028,7 @@ class SessionKeyGenerator(object): token = self._get_web_auth_token() url = "{homepage}/api/auth/?api_key={api}&token={token}".format( - homepage=self.network.homepage, - api=self.network.api_key, - token=token, + homepage=self.network.homepage, api=self.network.api_key, token=token ) self.web_auth_tokens[url] = token