Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python 3.7 deprecation warnings #79

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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