Skip to content

Commit

Permalink
Merge pull request #152 from mollie/prepare-for-2.3.0-release
Browse files Browse the repository at this point in the history
Prepare for 2.3.0 release
  • Loading branch information
kingel committed Dec 23, 2019
2 parents ac10890 + 612cb28 commit 282e961
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
14 changes: 2 additions & 12 deletions mollie/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions mollie/api/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
2 changes: 1 addition & 1 deletion mollie/api/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 0 additions & 8 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 282e961

Please sign in to comment.