Skip to content

Commit

Permalink
Fix uplink with Python 2.7 (#223)
Browse files Browse the repository at this point in the history
* Fix uplink with Python 2.7

* Switch on six.moves.collections_abc

* Add abc in __all__

* Add link to GitHub Discussions for repo in README

* Update "Question" GitHub issue template

* Fix @uplink.*Map to not throw error if converter is None

Fixes #221

* Fix B018 flake error

Flake is failing with "B018 Found useless expression."

https://app.travis-ci.com/github/prkumar/uplink/jobs/553555288

* Add 3.9 and 3.10.1 to travis build (#239)

* Add 3.9 and 3.10 to travis build

* Replace 3.10 with 3.10-dev

* Update travis to use Ubuntu 18.04

18.04 has 3.10.0 and 3.10.1 according to: 
https://docs.travis-ci.com/user/languages/python/

* Bump python 3.10 to 3.10.1 in travis

* Unpin pytest version

Travis build for 3.10.1 failed because of issue in pytest that was fixed in a later release: pytest-dev/pytest#8540

* Fix uplink with Python 2.7

* Switch on six.moves.collections_abc

* Add abc in __all__

* Add python 2.7 to travis build

* Omit "keywords" attribute when invoking setup for py2.7

Context: pypa/pipenv#4357 (comment)

* Pin pipenv==2018.11.26 for py2.7 travis build

Context: pypa/pipenv#4357 (comment)

* Fix syntax error in travis config file

* Try pinning pipenv version in tox.ini

* Make integration tests work with py2.7

* Make integration tests work with py2.7

* Fix flake8 E231 error

Co-authored-by: P. Raj Kumar <raj.pritvi.kumar@gmail.com>
Co-authored-by: Alexander Shadchinr <shadchin@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 31, 2021
1 parent 418bc54 commit a660529
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 25 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/ambv/black
rev: 18.6b4
rev: 21.12b0
hooks:
- id: black
python-version: python3.6
python-version: python3.8
files: ^((uplink|examples|tests)\/.+|setup|docs\/conf)\.py$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
- repo: https://github.com/pycqa/flake8
rev: '4.0.1'
hooks:
- id: flake8
name: flake8
python-version: python3.6
python-version: python3.8
files: ^((uplink|examples|tests)\/.+|setup|docs\/conf)\.py$
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: python
dist: bionic # Ubuntu 18.04
python:
- '2.7'
- '3.5'
- '3.6'
- '3.7'
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Contributors
- Sakorn Waungwiwatsin (`@SakornW <https://github.com/SakornW>`_)
- Jacob Floyd (`@cognifloyd <https://github.com/cognifloyd>`_)
- Guilherme Crocetti (`@gmcrocetti <https://github.com/gmcrocetti/>`_)
- Alexander Shadchin (`@shadchin <https://github.com/shadchin>`_)
4 changes: 2 additions & 2 deletions tests/integration/test_form_url_encoded.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
def test_without_converter(mock_response, mock_client):
class Calendar(Consumer):
@form_url_encoded
@put("/user/repos")
def add_event(self, **event_data: FieldMap):
@put("/user/repos", args={"event_data": FieldMap})
def add_event(self, **event_data):
pass

mock_client.with_response(mock_response)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
def test_without_converter(mock_response, mock_client):
class Calendar(Consumer):
@multipart
@post("/attachments")
def upload_attachments(self, **files: PartMap):
@post("/attachments", args={"files": PartMap})
def upload_attachments(self, **files):
pass

mock_client.with_response(mock_response)
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Website (June 2016): http://tox.readthedocs.io/en/latest/

[testenv]
deps = pipenv
deps =
pipenv == 2018.11.26 ; python_version == '2.7'
pipenv ; python_version > '2.7'
commands = pipenv install --skip-lock
pipenv run py.test tests \
--cov-config .coveragerc \
Expand Down
2 changes: 1 addition & 1 deletion uplink/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"""
# Standard library imports
import collections
from collections import abc
import functools
import inspect

# Local imports
from uplink import exceptions, hooks, interfaces, utils
from uplink.compat import abc
from uplink.converters import keys

__all__ = [
Expand Down
4 changes: 1 addition & 3 deletions uplink/auth.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""This module implements the auth layer."""

# Standard library imports
from collections import abc

# Third-party imports
from requests import auth

# Local imports
from uplink import utils
from uplink.compat import abc

__all__ = [
"ApiTokenParam",
Expand Down
5 changes: 1 addition & 4 deletions uplink/clients/io/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Standard library imports
from collections import abc

# Local imports
from uplink import compat

Expand Down Expand Up @@ -69,7 +66,7 @@ def on_failure(self, exc_type, exc_val, exc_tb):
raise NotImplementedError


class Executable(abc.Iterator):
class Executable(compat.abc.Iterator):
"""An abstraction for iterating over the execution of a request."""

def __next__(self):
Expand Down
2 changes: 1 addition & 1 deletion uplink/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Standard library imports
from collections import abc
import functools

# Local imports
Expand All @@ -12,6 +11,7 @@
returns,
utils,
)
from uplink.compat import abc

__all__ = ["get", "head", "put", "post", "patch", "delete"]

Expand Down
3 changes: 2 additions & 1 deletion uplink/compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Third-party imports
import six

__all__ = ["reraise"]
__all__ = ["abc", "reraise"]

abc = six.moves.collections_abc
reraise = six.reraise
4 changes: 1 addition & 3 deletions uplink/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Standard library imports
from collections import abc

# Local imports
from uplink._extras import installer, plugin
from uplink.compat import abc
from uplink.converters import keys
from uplink.converters.interfaces import Factory, ConverterFactory, Converter
from uplink.converters.register import (
Expand Down
2 changes: 1 addition & 1 deletion uplink/converters/typing_.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Standard library imports
import collections
from collections import abc
import functools

# Local imports
from uplink.compat import abc
from uplink.converters import interfaces, register_default_converter_factory

__all__ = ["TypingConverter", "ListConverter", "DictConverter"]
Expand Down
2 changes: 1 addition & 1 deletion uplink/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
handling classes.
"""
# Standard library imports
from collections import abc
import functools
import inspect

# Local imports
from uplink import arguments, helpers, hooks, interfaces, utils
from uplink.compat import abc

__all__ = [
"headers",
Expand Down

0 comments on commit a660529

Please sign in to comment.