From 0a5d93e7b32dc27fd2ceb3c5141225f750fa8b6b Mon Sep 17 00:00:00 2001 From: Tom Hendrikx Date: Mon, 23 Dec 2019 14:19:06 +0100 Subject: [PATCH 1/3] Remove support for setting api_key during client init. --- mollie/api/client.py | 14 ++------------ tests/test_client.py | 8 -------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/mollie/api/client.py b/mollie/api/client.py index 35438513..2a968e41 100644 --- a/mollie/api/client.py +++ b/mollie/api/client.py @@ -2,14 +2,13 @@ import platform import re import ssl -import warnings from collections import OrderedDict from urllib.parse import urlencode import requests from requests_oauthlib import OAuth2Session -from .error import RemovedIn23Warning, RequestError, RequestSetupError +from .error import RequestError, RequestSetupError from .resources.captures import Captures from .resources.chargebacks import Chargebacks from .resources.customer_mandates import CustomerMandates @@ -72,7 +71,7 @@ def validate_access_token(access_token): access_token=access_token)) return access_token - def __init__(self, api_key=None, api_endpoint=None, timeout=10): + def __init__(self, api_endpoint=None, timeout=10): self.api_endpoint = self.validate_api_endpoint(api_endpoint or self.API_ENDPOINT) self.api_version = self.API_VERSION self.timeout = timeout @@ -120,15 +119,6 @@ def __init__(self, api_key=None, api_endpoint=None, timeout=10): self.set_user_agent_component('OpenSSL', ssl.OPENSSL_VERSION.split(' ')[1], sanitize=False) # keep legacy formatting of this component - if api_key: - # There is no clean way for supporting both API key and access token acceptance and validation - # in __init__(). Furthermore the naming of the parameter would be inconsistent. - # Using class methods is way cleaner. - msg = "Setting the API key during init will be removed in the future. " \ - "Use Client.set_api_key() or Client.set_access_token() instead." - warnings.warn(msg, RemovedIn23Warning) - self.api_key = self.validate_api_key(api_key) - def set_api_endpoint(self, api_endpoint): self.api_endpoint = self.validate_api_endpoint(api_endpoint) diff --git a/tests/test_client.py b/tests/test_client.py index 6871eaa1..0798ac4b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -92,14 +92,6 @@ def test_client_invalid_api_key(): client.set_access_token('test_123') -def test_client_api_key_during_init_deprecated(recwarn): - """Setting the api key during init should work but raise a warning.""" - with pytest.warns(DeprecationWarning, - match='Setting the API key during init will be removed in the future'): - client = Client(api_key='test_123') - assert client.api_key == 'test_123' - - def test_client_broken_cert_bundle(monkeypatch): """A request should raise an error when the certificate bundle is not available. From ee6d53f0924a359a16a84a5187f75142722ad697 Mon Sep 17 00:00:00 2001 From: Tom Hendrikx Date: Mon, 23 Dec 2019 14:22:54 +0100 Subject: [PATCH 2/3] Rename warning subclasses. --- mollie/api/error.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mollie/api/error.py b/mollie/api/error.py index 5f1bd21c..23947173 100644 --- a/mollie/api/error.py +++ b/mollie/api/error.py @@ -94,7 +94,7 @@ class DataConsistencyError(Error): Deprecation policy When a minor version release will be done, remove all code that triggers the DeprecationWarning subclass. -Then rename the DeprecationWarning subclass to the next minor version (RemovedIn23Warning => RemovedIn24Warning). +Then rename the DeprecationWarning subclass to the next minor version (RemovedIn24Warning => RemovedIn25Warning). and rename the PendingDeprecation subclass below also. This will make all existing PendingDeprecationWarnings change to DeprecationWarnings. @@ -104,13 +104,13 @@ class DataConsistencyError(Error): """ -class RemovedIn23Warning(DeprecationWarning): - """Deprecation warning for features that will be removed in version 2.3.0.""" +class RemovedIn24Warning(DeprecationWarning): + """Deprecation warning for features that will be removed in version 2.4.0.""" pass -class RemovedIn24Warning(PendingDeprecationWarning): - """Pending deprecation warning for features that will be removed in version 2.4.0.""" +class RemovedIn25Warning(PendingDeprecationWarning): + """Pending deprecation warning for features that will be removed in version 2.5.0.""" pass From 612cb28df22827c73adf2091733bd2f409bd0542 Mon Sep 17 00:00:00 2001 From: Tom Hendrikx Date: Mon, 23 Dec 2019 14:23:37 +0100 Subject: [PATCH 3/3] Set version to 2.3.0 --- mollie/api/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mollie/api/version.py b/mollie/api/version.py index 8ae9bf97..1e418e31 100644 --- a/mollie/api/version.py +++ b/mollie/api/version.py @@ -4,4 +4,4 @@ # processed by python imports and by regular expressions. The version is defined as a string in the # regular semantic versioning scheme (major,minor,patch). -VERSION = '2.2.4' +VERSION = '2.3.0'