diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index ba377ae..f218959 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -3,11 +3,11 @@ We appreciate the effort for this pull request but before that please make sure Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! -e.g. +e.g. Fixes #1 Closes #2 --> -# Fixes # +# Fixes # ### Checklist - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) @@ -18,7 +18,7 @@ Closes #2 - [ ] I have added in line documentation to the code I modified ### Short description of what this PR does: -- -- +- +- -If you have questions, please send an email to [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository. \ No newline at end of file +If you have questions, please send an email to [SendGrid](mailto:dx@sendgrid.com), or file a GitHub Issue in this repository. diff --git a/.travis.yml b/.travis.yml index 12084cc..f7bb244 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python sudo: false cache: pip python: -- '2.6' - '2.7' - '3.4' - '3.5' @@ -18,19 +17,16 @@ before_install: - pip install pycodestyle install: - pip install codecov -- if [[ "$TRAVIS_PYTHON_VERSION" == 2.6* ]]; then travis_retry pip install unittest2; fi -- if [[ "$TRAVIS_PYTHON_VERSION" == 2.6* ]]; then travis_retry pip uninstall -y pbr; fi -- if [[ "$TRAVIS_PYTHON_VERSION" == "3.2" ]]; then travis_retry pip install coverage==3.7.1; fi -- if [[ "$TRAVIS_PYTHON_VERSION" != "3.2" ]]; then travis_retry pip install coverage; fi +- travis_retry pip install coverage - python setup.py install - pip install codecov script: -- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then coverage run -m unittest2 discover; else coverage run -m unittest discover; fi +- coverage run -m unittest discover after_script: - codecov # Run pycodestyle - pycodestyle -- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then unit2 discover; else python -m unittest discover; fi +- python -m unittest discover - coverage run tests/test_unit.py notifications: hipchat: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 356845d..77f8359 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,7 +47,7 @@ A software bug is a demonstrable issue in the code base. In order for us to diag Before you decide to create a new issue, please try the following: -1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post. +1. Check the GitHub issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post. 2. Update to the latest version of this code and check if issue has already been fixed 3. Copy and fill in the Bug Report Template we have provided below @@ -66,7 +66,7 @@ We welcome direct contributions to the python-http-client code base. Thank you! ##### Prerequisites ##### -- Python 2.6, 2.7 or 3.3+ +- Python 2.7 and 3.4+ - There are no external dependencies ##### Initial setup: ##### @@ -112,14 +112,6 @@ All test files are in the [`tests`](https://github.com/sendgrid/python-http-clie For the purposes of contributing to this repo, please update the [`test_unit.py`](https://github.com/sendgrid/python-http-client/blob/master/test/test_unit.py) file with unit tests as you modify the code. -For Python 2.6.*: - -```bash -unit2 discover -v -``` - -For Python 2.7.* and up: - ```bash python -m unittest discover -v ``` @@ -141,13 +133,12 @@ The above local "Initial setup" is complete Add `eval "$(pyenv init -)"` to your shell environment (.profile, .bashrc, etc) after installing tox, you only need to do this once. ```bash -pyenv install 2.6.9 pyenv install 2.7.11 pyenv install 3.4.3 pyenv install 3.5.2 pyenv install 3.6.0 python setup.py install -pyenv local 3.6.0 3.5.2 3.4.3 2.7.8 2.6.9 +pyenv local 3.6.0 3.5.2 3.4.3 2.7.8 pyenv rehash ``` @@ -229,4 +220,4 @@ If you have any additional questions, please feel free to [email](mailto:dx@send ## Code Reviews -If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, Github has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/). +If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, GitHub has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/). diff --git a/Dockerfile b/Dockerfile index 41bfe79..e41de49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:xenial -ENV PYTHON_VERSIONS='python2.6 python2.7 python3.4 python3.5 python3.6 python3.7' \ +ENV PYTHON_VERSIONS='python2.7 python3.4 python3.5 python3.6 python3.7' \ OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json" # install testing versions of python, including old versions, from deadsnakes diff --git a/README.md b/README.md index d1c62ad..d77e674 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ If you are looking for the SendGrid API client library, please see [this repo](h ## Prerequisites -- Python version 2.6, 2.7, 3.4, 3.5 or 3.6 +- Python version 2.7 or 3.4+ ## Install Package diff --git a/examples/live_sendgrid_example.py b/examples/live_sendgrid_example.py index 01a0545..9c1061d 100644 --- a/examples/live_sendgrid_example.py +++ b/examples/live_sendgrid_example.py @@ -5,7 +5,7 @@ host = "https://api.sendgrid.com" api_key = os.environ.get('SENDGRID_API_KEY') request_headers = { - "Authorization": 'Bearer {0}'.format(api_key) + "Authorization": 'Bearer {}'.format(api_key) } version = 3 # we could also use client.version(3) client = python_http_client.Client(host=host, diff --git a/python_http_client/client.py b/python_http_client/client.py index 74d6ed9..5767d57 100644 --- a/python_http_client/client.py +++ b/python_http_client/client.py @@ -102,7 +102,7 @@ def _build_versioned_url(self, url): :type url: string :return: string """ - return '{0}/v{1}{2}'.format(self.host, str(self._version), url) + return '{}/v{}{}'.format(self.host, str(self._version), url) def _build_url(self, query_params): """Build the final URL to be passed to urllib @@ -114,7 +114,7 @@ def _build_url(self, query_params): url = '' count = 0 while count < len(self._url_path): - url += '/{0}'.format(self._url_path[count]) + url += '/{}'.format(self._url_path[count]) count += 1 # add slash @@ -123,7 +123,7 @@ def _build_url(self, query_params): if query_params: url_values = urlencode(sorted(query_params.items()), True) - url = '{0}?{1}'.format(url, url_values) + url = '{}?{}'.format(url, url_values) if self._version: url = self._build_versioned_url(url) diff --git a/setup.py b/setup.py index 52fa6a9..9b6cbc6 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -import sys import os from setuptools import setup @@ -8,13 +7,6 @@ long_description = open('README.txt').read() -def get_requires(): - deps = [] - if (2, 6) <= sys.version_info < (2, 7): - deps.append('unittest2') - return deps - - base_url = 'https://github.com/sendgrid/' version = '3.1.0' setup( @@ -22,22 +14,20 @@ def get_requires(): version=version, author='Elmer Thomas', author_email='dx@sendgrid.com', - url='{0}python-http-client'.format(base_url), - download_url='{0}python-http-client/tarball/{1}'.format(base_url, version), + url='{}python-http-client'.format(base_url), + download_url='{}python-http-client/tarball/{}'.format(base_url, version), packages=['python_http_client'], license='MIT', description='HTTP REST client, simplified for Python', long_description=long_description, - install_requires=get_requires(), keywords=[ 'REST', 'HTTP', 'API'], + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', classifiers=[ - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6' diff --git a/tests/profile.py b/tests/profile.py index 94fb158..4b241e5 100644 --- a/tests/profile.py +++ b/tests/profile.py @@ -131,13 +131,13 @@ def run_tested_code(client, num_loops): @timefunc def dynamic_version(): - local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__))) + local_path = '{}/..'.format(os.path.abspath(os.path.dirname(__file__))) Config(local_path) api_key = os.environ.get('SENDGRID_API_KEY') request_headers = { 'X-Mock': 200, 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(api_key) + 'Authorization': 'Bearer {}'.format(api_key) } client = Client(host=os.environ.get('LOCAL_HOST'), request_headers=request_headers, @@ -147,13 +147,13 @@ def dynamic_version(): @timefunc def static_version(): - local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__))) + local_path = '{}/..'.format(os.path.abspath(os.path.dirname(__file__))) Config(local_path) api_key = os.environ.get('SENDGRID_API_KEY') request_headers = { 'X-Mock': 200, 'Content-Type': 'application/json', - 'Authorization': 'Bearer {0}'.format(api_key) + 'Authorization': 'Bearer {}'.format(api_key) } client = StaticClient(host=os.environ.get('LOCAL_HOST'), request_headers=request_headers, diff --git a/tests/test_daterange.py b/tests/test_daterange.py index 1cb206b..0916ba1 100644 --- a/tests/test_daterange.py +++ b/tests/test_daterange.py @@ -1,10 +1,6 @@ import os import time - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest class DateRangeTest(unittest.TestCase): @@ -19,5 +15,4 @@ def setUp(self): fh.close() def test__daterange(self): - self.assertTrue(self.pattern in self.licensefile) - + self.assertIn(self.pattern, self.licensefile) diff --git a/tests/test_repofiles.py b/tests/test_repofiles.py index 544ce77..30c8beb 100644 --- a/tests/test_repofiles.py +++ b/tests/test_repofiles.py @@ -1,8 +1,5 @@ +import unittest from os import path -try: - import unittest2 as unittest -except ImportError: - import unittest class RepoFiles(unittest.TestCase): @@ -34,5 +31,5 @@ def _all_file(self, files): def test_file_existence(self): missing = list(filter(self._all_file, self.FILES)) - self.assertTrue(len(missing) == 0, - "Files %s aren't found" % str(missing)) + self.assertEqual(len(missing), 0, + "Files %s aren't found" % str(missing)) diff --git a/tests/test_unit.py b/tests/test_unit.py index 3ac7046..8ca2b66 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -1,9 +1,6 @@ import pickle +import unittest -try: - import unittest2 as unittest -except ImportError: - import unittest from python_http_client.client import Client from python_http_client.exceptions import ( handle_error, @@ -86,7 +83,7 @@ def test__init__(self): self.assertIs(default_client.timeout, None) methods = ['delete', 'get', 'patch', 'post', 'put'] self.assertEqual(default_client.methods, methods) - self.assertEqual(default_client._version, None) + self.assertIsNone(default_client._version) self.assertEqual(default_client._url_path, []) request_headers = {'X-Test': 'test', 'X-Test2': 1} @@ -106,7 +103,7 @@ def test__init__(self): def test__build_versioned_url(self): url = '/api_keys?hello=1&world=2' versioned_url = self.client._build_versioned_url(url) - url = '{0}/v{1}{2}'.format(self.host, str(self.client._version), url) + url = '{}/v{}{}'.format(self.host, str(self.client._version), url) self.assertEqual(versioned_url, url) def test__build_url(self): @@ -114,7 +111,7 @@ def test__build_url(self): self.client._url_path = self.client._url_path + ['there'] self.client._url_path = self.client._url_path + [1] self.client._version = 3 - url = '{0}/v{1}{2}'.format( + url = '{}/v{}{}'.format( self.host, str(self.client._version), '/here/there/1?hello=0&world=1&ztest=0&ztest=1' @@ -126,7 +123,7 @@ def test__build_url(self): def test__update_headers(self): request_headers = {'X-Test': 'Test'} self.client._update_headers(request_headers) - self.assertTrue('X-Test' in self.client.request_headers) + self.assertIn('X-Test', self.client.request_headers) self.client.request_headers.pop('X-Test', None) def test__build_client(self): diff --git a/tox.ini b/tox.ini index b9fafbc..df28e5b 100644 --- a/tox.ini +++ b/tox.ini @@ -4,32 +4,17 @@ # and then run "tox" from this directory. [tox] -envlist = py26, py27, py32, py33, py34, py35, py36, py37 +envlist = py27, py34, py35, py36, py37 [testenv] commands = {envbindir}/python -m unittest discover -v [] deps = -[testenv:py26] -commands = {envbindir}/unit2 discover -v [] -deps = -basepython = python2.6 - [testenv:py27] commands = {envbindir}/python -m unittest discover -v [] deps = basepython = python2.7 -[testenv:py32] -commands = {envbindir}/python -m unittest discover -v [] -deps = -basepython = python3.2 - -[testenv:py33] -commands = {envbindir}/python -m unittest discover -v [] -deps = -basepython = python3.3 - [testenv:py34] commands = {envbindir}/python -m unittest discover -v [] deps =