Apply PR feedback

This commit is contained in:
Alex Stokes 2019-12-10 17:07:21 -08:00
parent d516cf51b8
commit 3b9d7c7acd
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086
7 changed files with 29 additions and 23 deletions

View File

@ -48,24 +48,30 @@ jobs:
- image: circleci/python:3.6
environment:
TOXENV: lint
py36-test:
py36-core:
<<: *common
docker:
- image: circleci/python:3.6
environment:
TOXENV: py36-test
py37-test:
TOXENV: py36-core
py37-core:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV: py37-test
TOXENV: py37-core
pypy3-core:
<<: *common
docker:
- image: pypy
environment:
TOXENV: pypy3-core
workflows:
version: 2
test:
jobs:
- docs
- lint
- py36-test
- py37-test
- py36-core
- py37-core
- pypy3-core

View File

@ -53,5 +53,6 @@ class RawConnection(IRawConnection):
async def close(self) -> None:
self.writer.close()
if sys.version_info[0:2] > (3, 6):
if sys.version_info < (3, 7):
return
await self.writer.wait_closed()

View File

@ -1,6 +1,8 @@
import asyncio
from typing import Any, AsyncIterator, Dict, Tuple, cast
# NOTE: import ``asynccontextmanager`` from ``contextlib`` when support for python 3.6 is dropped.
from async_generator import asynccontextmanager
import factory
from libp2p import generate_new_rsa_identity, generate_peer_id_from
@ -32,12 +34,6 @@ from .constants import (
)
from .utils import connect, connect_swarm
try:
from contextlib import asynccontextmanager
except ImportError:
# NOTE: mypy complains about a duplicate import without the following ``# type: ignore``
from async_generator import asynccontextmanager # type: ignore
def initialize_peerstore_with_our_keypair(self_id: ID, key_pair: KeyPair) -> PeerStore:
peer_store = PeerStore()
@ -177,7 +173,7 @@ async def host_pair_factory(is_secure: bool) -> Tuple[BasicHost, BasicHost]:
return hosts[0], hosts[1]
@asynccontextmanager
@asynccontextmanager # type: ignore
async def pair_of_connected_hosts(
is_secure: bool = True
) -> AsyncIterator[Tuple[BasicHost, BasicHost]]:

View File

@ -54,9 +54,11 @@ class TCPListener(IListener):
if self.server is None:
return
self.server.close()
if sys.version_info[0:2] > (3, 6):
await self.server.wait_closed()
server = self.server
self.server = None
if sys.version_info < (3, 7):
return
await server.wait_closed()
class TCP(ITransport):

View File

@ -59,7 +59,7 @@ install_requires = [
"coincurve>=10.0.0,<11.0.0",
"pynacl==1.3.0",
"dataclasses>=0.7, <1;python_version<'3.7'",
"async_generator==1.10;python_version<'3.7'",
"async_generator==1.10",
]
@ -96,6 +96,7 @@ setup(
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
platforms=["unix", "linux", "osx"],

View File

@ -151,7 +151,8 @@ class DaemonStream(ReadWriteCloser):
async def close(self) -> None:
self.writer.close()
if sys.version_info[0:2] > (3, 6):
if sys.version_info < (3, 7):
return
await self.writer.wait_closed()
async def read(self, n: int = -1) -> bytes:

View File

@ -3,8 +3,7 @@
# TODO: consider pypy3 support
[tox]
envlist =
py36-test
py37-test
py{36,37}-test
py37-interop
lint
docs