From 02924cd44352b29a05aca6d0e41dc55d1e8f0c1b Mon Sep 17 00:00:00 2001 From: Jeffrey Meadows Date: Thu, 29 Mar 2018 11:47:17 -0700 Subject: [PATCH 1/2] Drop support for py2.6 and py3.3. This commit removes testing for those platforms. This commit also makes changes so that CI passes again, including several pylint warning suppressions. This commit also starts using pycodestyle instead of the deprecated pep8 package name. --- HISTORY.rst | 2 ++ boxsdk/auth/cooperatively_managed_oauth2.py | 1 + boxsdk/auth/oauth2.py | 4 +++- boxsdk/auth/redis_managed_oauth2.py | 20 +++++++++++--------- boxsdk/auth/remote_managed_oauth2.py | 1 + boxsdk/network/default_network.py | 1 + boxsdk/object/file.py | 2 +- docs/source/boxsdk.object.rst | 8 ++++++++ docs/source/boxsdk.rst | 1 + setup.py | 5 ++--- test/functional/conftest.py | 2 +- test/unit/auth/test_oauth2.py | 5 ++++- test/unit/object/test_item.py | 3 +-- test/unit/util/test_api_call_decorator.py | 5 +++-- tox.ini | 12 +++++------- 15 files changed, 45 insertions(+), 27 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 19f44d642..5d3b31b22 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,8 @@ Release History **Breaking Changes** +- Python 2.6 is no longer supported. +- Python 3.3 is no longer supported. - ``Events.get_events(...)`` now returns a list of ``Event`` instances rather than a list of ``dict`` representing events. ``Event`` inherits from ``Mapping`` but will not have all the same capabilities as ``dict``. diff --git a/boxsdk/auth/cooperatively_managed_oauth2.py b/boxsdk/auth/cooperatively_managed_oauth2.py index 84ee3479c..9c3c32d54 100644 --- a/boxsdk/auth/cooperatively_managed_oauth2.py +++ b/boxsdk/auth/cooperatively_managed_oauth2.py @@ -16,6 +16,7 @@ def __init__(self, retrieve_tokens=None, *args, **kwargs): :type retrieve_tokens: `callable` of () => (`unicode`, `unicode`) """ + # pylint:disable=keyword-arg-before-vararg self._retrieve_tokens = retrieve_tokens super(CooperativelyManagedOAuth2Mixin, self).__init__(*args, **kwargs) diff --git a/boxsdk/auth/oauth2.py b/boxsdk/auth/oauth2.py index e3b2895bb..5d70e0c0b 100644 --- a/boxsdk/auth/oauth2.py +++ b/boxsdk/auth/oauth2.py @@ -9,7 +9,9 @@ import sys import six -from six.moves.urllib.parse import urlencode, urlunsplit # pylint:disable=import-error,no-name-in-module +# pylint:disable=import-error,no-name-in-module,relative-import +from six.moves.urllib.parse import urlencode, urlunsplit +# pylint:enable=import-error,no-name-in-module,relative-import from boxsdk.config import API from boxsdk.exception import BoxOAuthException diff --git a/boxsdk/auth/redis_managed_oauth2.py b/boxsdk/auth/redis_managed_oauth2.py index a8d85aca7..3915bff55 100644 --- a/boxsdk/auth/redis_managed_oauth2.py +++ b/boxsdk/auth/redis_managed_oauth2.py @@ -14,17 +14,19 @@ class RedisManagedOAuth2Mixin(OAuth2): """ Box SDK OAuth2 subclass. Allows for storing auth tokens in redis. - - :param unique_id: - An identifier for this auth object. Auth instances which wish to share tokens must use the same ID. - :type unique_id: - `unicode` - :param redis_server: - An instance of a Redis server, configured to talk to Redis. - :type redis_server: - :class:`Redis` """ def __init__(self, unique_id=uuid4(), redis_server=None, *args, **kwargs): + """ + :param unique_id: + An identifier for this auth object. Auth instances which wish to share tokens must use the same ID. + :type unique_id: + `unicode` + :param redis_server: + An instance of a Redis server, configured to talk to Redis. + :type redis_server: + :class:`Redis` + """ + # pylint:disable=keyword-arg-before-vararg self._unique_id = unique_id self._redis_server = redis_server or StrictRedis() refresh_lock = Lock(redis=self._redis_server, name='{0}_lock'.format(self._unique_id)) diff --git a/boxsdk/auth/remote_managed_oauth2.py b/boxsdk/auth/remote_managed_oauth2.py index 0ed4ba4c3..9a8bb7ca9 100644 --- a/boxsdk/auth/remote_managed_oauth2.py +++ b/boxsdk/auth/remote_managed_oauth2.py @@ -17,6 +17,7 @@ def __init__(self, retrieve_access_token=None, *args, **kwargs): :type retrieve_access_token: `callable` of `unicode` => `unicode` """ + # pylint:disable=keyword-arg-before-vararg self._retrieve_access_token = retrieve_access_token super(RemoteOAuth2Mixin, self).__init__(*args, **kwargs) diff --git a/boxsdk/network/default_network.py b/boxsdk/network/default_network.py index 59ea9df92..fede1bea5 100644 --- a/boxsdk/network/default_network.py +++ b/boxsdk/network/default_network.py @@ -20,6 +20,7 @@ def request(self, method, url, access_token, **kwargs): """Base class override. Make a network request using a requests.Session. """ + # pylint:disable=abstract-class-instantiated return self.network_response_constructor( request_response=self._session.request(method, url, **kwargs), access_token_used=access_token, diff --git a/boxsdk/object/file.py b/boxsdk/object/file.py index a0ebee72e..de31fe575 100644 --- a/boxsdk/object/file.py +++ b/boxsdk/object/file.py @@ -278,4 +278,4 @@ def get_shared_link_download_url( allow_preview=allow_preview, password=password, ) - return item.shared_link['download_url'] + return item.shared_link['download_url'] # pylint:disable=no-member diff --git a/docs/source/boxsdk.object.rst b/docs/source/boxsdk.object.rst index 6b337479c..d67d62cbf 100644 --- a/docs/source/boxsdk.object.rst +++ b/docs/source/boxsdk.object.rst @@ -116,6 +116,14 @@ boxsdk.object.metadata module :undoc-members: :show-inheritance: +boxsdk.object.recent_item module +-------------------------------- + +.. automodule:: boxsdk.object.recent_item + :members: + :undoc-members: + :show-inheritance: + boxsdk.object.search module --------------------------- diff --git a/docs/source/boxsdk.rst b/docs/source/boxsdk.rst index 750443609..596cc624a 100644 --- a/docs/source/boxsdk.rst +++ b/docs/source/boxsdk.rst @@ -10,6 +10,7 @@ Subpackages boxsdk.client boxsdk.network boxsdk.object + boxsdk.pagination boxsdk.session boxsdk.util diff --git a/setup.py b/setup.py index 272147bbd..34636839a 100644 --- a/setup.py +++ b/setup.py @@ -17,9 +17,7 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -87,7 +85,8 @@ def main(): 'bottle', 'jsonpatch', 'mock>=2.0.0', - 'pep8', 'pylint', + 'pycodestyle', + 'pylint', 'sqlalchemy', 'tox', 'pytest-cov', diff --git a/test/functional/conftest.py b/test/functional/conftest.py index 987cc4862..7984c564b 100644 --- a/test/functional/conftest.py +++ b/test/functional/conftest.py @@ -8,7 +8,7 @@ import pytest import requests import six -from six.moves.urllib import parse # pylint:disable=import-error, no-name-in-module,wrong-import-order +from six.moves.urllib import parse # pylint:disable=import-error, no-name-in-module,wrong-import-order,relative-import from boxsdk.auth.oauth2 import OAuth2 from boxsdk.config import API diff --git a/test/unit/auth/test_oauth2.py b/test/unit/auth/test_oauth2.py index 798af3775..f4898f6bf 100644 --- a/test/unit/auth/test_oauth2.py +++ b/test/unit/auth/test_oauth2.py @@ -10,7 +10,9 @@ from mock import Mock, patch import pytest from six.moves import range # pylint:disable=redefined-builtin -from six.moves.urllib import parse as urlparse # pylint:disable=import-error,no-name-in-module,wrong-import-order +# pylint:disable=import-error,no-name-in-module,wrong-import-order,relative-import +from six.moves.urllib import parse as urlparse +# pylint:enable=import-error,no-name-in-module,wrong-import-order,relative-import from boxsdk.exception import BoxOAuthException from boxsdk.network.default_network import DefaultNetworkResponse @@ -204,6 +206,7 @@ def token_method(request): return partial(OAuth2.refresh, access_token_to_refresh='fake_access_token') elif request.param == OAuth2.authenticate: return partial(OAuth2.authenticate, auth_code='fake_code') + return None @pytest.mark.parametrize( diff --git a/test/unit/object/test_item.py b/test/unit/object/test_item.py index 7d0c9cbe0..73e5673bc 100644 --- a/test/unit/object/test_item.py +++ b/test/unit/object/test_item.py @@ -9,8 +9,7 @@ def test_item_and_response(test_file, test_folder, mock_file_response, mock_folder_response, request): if request.param == 'file': return test_file, mock_file_response - elif request.param == 'folder': - return test_folder, mock_folder_response + return test_folder, mock_folder_response def test_update_info(test_item_and_response, mock_box_session, etag, if_match_header): diff --git a/test/unit/util/test_api_call_decorator.py b/test/unit/util/test_api_call_decorator.py index ab395f08c..f86778391 100644 --- a/test/unit/util/test_api_call_decorator.py +++ b/test/unit/util/test_api_call_decorator.py @@ -2,11 +2,12 @@ from __future__ import absolute_import, unicode_literals -from boxsdk.object.cloneable import Cloneable -from boxsdk.util.api_call_decorator import api_call from mock import NonCallableMock import pytest +from boxsdk.object.cloneable import Cloneable +from boxsdk.util.api_call_decorator import api_call + @pytest.fixture def api_call_result(): diff --git a/tox.ini b/tox.ini index b17762c93..85a840f95 100644 --- a/tox.ini +++ b/tox.ini @@ -5,14 +5,12 @@ [tox] envlist = - py26, py27, - py33, py34, py35, py36, pypy, - pep8, + pycodestyle, pylint, rst, docs, @@ -32,12 +30,12 @@ commands = rst2html.py --strict HISTORY.rst rst2html.py --strict CONTRIBUTING.rst -[testenv:pep8] +[testenv:pycodestyle] commands = - pep8 --ignore=E501,W292 boxsdk setup.py - pep8 --ignore=E501,W292 test + pycodestyle --ignore=E501,W292 boxsdk setup.py + pycodestyle --ignore=E501,W292 test deps = - pep8 + pycodestyle [testenv:pylint] commands = From a5dc73c76f42d8e3b2a55e0eea956de10a1fe4ab Mon Sep 17 00:00:00 2001 From: Jeffrey Meadows Date: Thu, 29 Mar 2018 12:05:35 -0700 Subject: [PATCH 2/2] update .travis.yml --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31239bb09..4aa3a59bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,12 +10,8 @@ before_cache: matrix: include: - - python: 2.6 - env: TOX_ENV=py26 - python: 2.7 env: TOX_ENV=py27 - - python: 3.3 - env: TOX_ENV=py33 - python: 3.4 env: TOX_ENV=py34 - python: 3.5 @@ -23,9 +19,9 @@ matrix: - python: 3.6 env: TOX_ENV=py36 - python: pypy - env: TOX_ENV=pypy PYPY_VERSION='2.7-5.8.0' + env: TOX_ENV=pypy PYPY_VERSION='2.7-5.10.0' - python: 2.7 - env: TOX_ENV=pep8 + env: TOX_ENV=pycodestyle - python: 2.7 env: TOX_ENV=pylint - python: 2.7