From 6a63d20a5d2e7184bfc5747b465818fb7eee6b49 Mon Sep 17 00:00:00 2001 From: sw23 Date: Fri, 30 Oct 2020 18:56:40 -0400 Subject: [PATCH 1/4] Fixing remaining stub mypy issues + run check-stubs to CI --- .github/workflows/build.yml | 2 +- shared-bindings/ipaddress/IPv4Address.c | 2 +- shared-bindings/socketpool/SocketPool.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64d43f4d98..8039883e34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,7 +68,7 @@ jobs: run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float working-directory: tests - name: Stubs - run: make stubs -j2 + run: make check-stubs -j2 - uses: actions/upload-artifact@v2 with: name: stubs diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index b2a10158ae..e027f32d65 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -126,7 +126,7 @@ const mp_obj_property_t ipaddress_ipv4address_version_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def __eq__(self, other: IPv4Address) -> bool: +//| def __eq__(self, other: object) -> bool: //| """Two Address objects are equal if their addresses and address types are equal.""" //| ... //| diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index b737b5fc2d..0cead525f8 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -58,7 +58,7 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t } -//| def socket(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> None: +//| def socket(self, family: int, type: int, proto: int) -> socketpool.Socket: //| """Create a new socket //| //| :param ~int family: AF_INET or AF_INET6 From 8e72b68e3de90f87261ce289dd7d3a28815cfd0b Mon Sep 17 00:00:00 2001 From: sw23 Date: Fri, 30 Oct 2020 19:16:26 -0400 Subject: [PATCH 2/4] Adding mypy to dep list and clarifying Stubs stage name --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8039883e34..07db88963b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: run: | sudo apt-get install -y eatmydata sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64 latexmk texlive-fonts-recommended texlive-latex-recommended texlive-latex-extra - pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid isort black awscli + pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid isort black awscli mypy - name: Versions run: | gcc --version @@ -67,7 +67,7 @@ jobs: - name: mpy Tests run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -j1 --via-mpy -d basics float working-directory: tests - - name: Stubs + - name: Build and Validate Stubs run: make check-stubs -j2 - uses: actions/upload-artifact@v2 with: From 1f179b331750fbe05ccb4caff44e985234c9ee71 Mon Sep 17 00:00:00 2001 From: sw23 Date: Fri, 30 Oct 2020 23:19:27 -0400 Subject: [PATCH 3/4] Adding socket and socketpool class attributes --- shared-bindings/socket/__init__.c | 15 ++++++++------- shared-bindings/socketpool/SocketPool.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 38840da5ea..2969b37149 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -49,7 +49,14 @@ STATIC const mp_obj_type_t socket_type; //| class socket: //| -//| def __init__(self, family: int, type: int, proto: int) -> None: +//| AF_INET = 2 +//| AF_INET6 = 10 +//| SOCK_STREAM = 1 +//| SOCK_DGRAM = 2 +//| SOCK_RAW = 3 +//| IPPROTO_TCP = 6 +//| +//| def __init__(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> None: //| """Create a new socket //| //| :param int family: AF_INET or AF_INET6 @@ -57,12 +64,6 @@ STATIC const mp_obj_type_t socket_type; //| :param int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)""" //| ... //| -//| AF_INET: int -//| AF_INET6: int -//| SOCK_STREAM: int -//| SOCK_DGRAM: int -//| SOCK_RAW: int -//| STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 0, 4, false); diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 0cead525f8..2234f359ef 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -57,8 +57,14 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(s); } - -//| def socket(self, family: int, type: int, proto: int) -> socketpool.Socket: +//| AF_INET = 0 +//| AF_INET6 = 1 +//| SOCK_STREAM = 0 +//| SOCK_DGRAM = 1 +//| SOCK_RAW = 2 +//| IPPROTO_TCP = 6 +//| +//| def socket(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> socketpool.Socket: //| """Create a new socket //| //| :param ~int family: AF_INET or AF_INET6 @@ -66,6 +72,7 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t //| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)""" //| ... //| + STATIC mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 0, 5, false); From 88fcf4ef7e001e547ed94747df5d22b6736c881c Mon Sep 17 00:00:00 2001 From: sw23 Date: Mon, 2 Nov 2020 19:59:07 -0500 Subject: [PATCH 4/4] Removing implementation-specific values for socket/socketpool class attributes --- shared-bindings/socket/__init__.c | 12 ++++++------ shared-bindings/socketpool/SocketPool.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 2969b37149..799bf28afa 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -49,12 +49,12 @@ STATIC const mp_obj_type_t socket_type; //| class socket: //| -//| AF_INET = 2 -//| AF_INET6 = 10 -//| SOCK_STREAM = 1 -//| SOCK_DGRAM = 2 -//| SOCK_RAW = 3 -//| IPPROTO_TCP = 6 +//| AF_INET: int +//| AF_INET6: int +//| SOCK_STREAM: int +//| SOCK_DGRAM: int +//| SOCK_RAW: int +//| IPPROTO_TCP: int //| //| def __init__(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> None: //| """Create a new socket diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 2234f359ef..73eeed2652 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -57,12 +57,12 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(s); } -//| AF_INET = 0 -//| AF_INET6 = 1 -//| SOCK_STREAM = 0 -//| SOCK_DGRAM = 1 -//| SOCK_RAW = 2 -//| IPPROTO_TCP = 6 +//| AF_INET: int +//| AF_INET6: int +//| SOCK_STREAM: int +//| SOCK_DGRAM: int +//| SOCK_RAW: int +//| IPPROTO_TCP: int //| //| def socket(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = IPPROTO_TCP) -> socketpool.Socket: //| """Create a new socket