Skip to content

Commit

Permalink
Merge pull request #79 from mrdon-reciprocity/fix-collections-depreca…
Browse files Browse the repository at this point in the history
…tion-warning

Fix Python 3.7 deprecation warnings
  • Loading branch information
syrusakbary committed Dec 14, 2019
2 parents d80d791 + 625ed30 commit 0d5366e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ python:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- pypy
cache: pip
install:
Expand All @@ -15,7 +17,7 @@ after_success:
matrix:
fast_finish: true
include:
- python: '3.6'
- python: '3.8'
script: |
# pip install pyre-check
# pyre --source-directory promise check
Expand Down
14 changes: 7 additions & 7 deletions promise/dataloader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from collections import Iterable, namedtuple
from collections import namedtuple
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
from functools import partial

from .promise import Promise, async_instance, get_default_scheduler
Expand Down Expand Up @@ -67,16 +71,12 @@ def __init__(
if cache is not None:
self.cache = cache

if get_cache_key is not None:
self.get_cache_key = get_cache_key
self.get_cache_key = get_cache_key or (lambda x: x)

self._promise_cache = cache_map or {}
self._queue = [] # type: List[Loader]
self._scheduler = scheduler

def get_cache_key(self, key): # type: ignore
return key

def load(self, key=None):
# type: (Hashable) -> Promise
"""
Expand Down Expand Up @@ -227,7 +227,7 @@ def on_promise_resolve(v):
# type: (Any) -> None
async_instance.invoke(fn, scheduler)

resolved_promise.then(on_promise_resolve) # type: Promise[None]
resolved_promise.then(on_promise_resolve)


def dispatch_queue(loader):
Expand Down
6 changes: 3 additions & 3 deletions promise/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _settle_promise(
if async_guaranteed:
promise._is_async_guaranteed = True # type: ignore
self._settle_promise_from_handler( # type: ignore
handler, value, promise
handler, value, promise # type: ignore
) # type: ignore
elif is_promise:
if async_guaranteed:
Expand Down Expand Up @@ -567,7 +567,7 @@ def _then(
did_reject=None, # type: Optional[Callable[[Exception], S]]
):
# type: (...) -> Promise[S]
promise = self.__class__()
promise = self.__class__() # type: Promise
target = self._target()

state = target._state
Expand Down Expand Up @@ -791,7 +791,7 @@ def for_dict(cls, m):
dict_type = type(m) # type: Type[Dict]

if not m:
return cls.resolve(dict_type())
return cls.resolve(dict_type()) # type: ignore

def handle_success(resolved_values):
# type: (List[S]) -> Dict[Hashable, S]
Expand Down
5 changes: 4 additions & 1 deletion promise/promise_list.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from functools import partial
from collections import Iterable
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable

if False:
from .promise import Promise
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
],
Expand Down

0 comments on commit 0d5366e

Please sign in to comment.