From bd1bbe647d67a2f653d8cf14a135b3cb74569c47 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Thu, 18 Aug 2022 19:20:29 +0100 Subject: [PATCH] :wrench: Check type hinting for all Python versions. Disable pylint check of Collection[int] as this is broken (https://github.com/PyCQA/pylint/issues/2377). --- .github/workflows/check-code-style.yaml | 18 ++++++++++++++++++ shui/__init__.py | 1 + shui/functions/response.py | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-code-style.yaml b/.github/workflows/check-code-style.yaml index a5a046a..b3a3db7 100644 --- a/.github/workflows/check-code-style.yaml +++ b/.github/workflows/check-code-style.yaml @@ -27,5 +27,23 @@ jobs: - name: Check style with pylint run: poetry run pylint shui --disable=C0301 + check-type-hinting: + name: Test type hinting + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python: ["3.6", "3.7", "3.8", "3.9", "3.10"] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Check type safety with mypy run: poetry run mypy shui diff --git a/shui/__init__.py b/shui/__init__.py index b70b00a..09ebcbd 100755 --- a/shui/__init__.py +++ b/shui/__init__.py @@ -1,3 +1,4 @@ +"""Base include for shui (Spark-Hadoop Unix Installer)""" import pkg_resources __version__ = pkg_resources.get_distribution("shui").version diff --git a/shui/functions/response.py b/shui/functions/response.py index dad1114..fe37f36 100644 --- a/shui/functions/response.py +++ b/shui/functions/response.py @@ -1,7 +1,7 @@ """Request with built-in retry""" +from typing import Collection from requests import Response, Session from requests.adapters import HTTPAdapter -from typing import Collection from urllib3.util.retry import Retry @@ -9,7 +9,7 @@ def get_with_retry( url: str, retries: int = 3, backoff_factor: float = 0.3, - status_forcelist: Collection[int] = (500, 502, 504), + status_forcelist: Collection[int] = (500, 502, 504), # pylint: disable=unsubscriptable-object ) -> Response: """Sends a GET request with retry options""" session = Session()