diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eea7339..b969f40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.7", "3.8", "3.9", "3.10" ] + python: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] name: python-${{ matrix.python }} steps: - name: Checkout diff --git a/docker-compose.yml b/docker-compose.yml index c4baf64..a00df7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,3 +37,21 @@ services: - .:/undictify working_dir: /undictify entrypoint: ./test/install_from_local_and_run_code_checks.sh + + unit-tests-3-11: + build: + context: . + dockerfile: test/Dockerfile_3.11 + volumes: + - .:/undictify + working_dir: /undictify + entrypoint: ./test/install_from_local_and_run_code_checks.sh + + unit-tests-3-12: + build: + context: . + dockerfile: test/Dockerfile_3.12 + volumes: + - .:/undictify + working_dir: /undictify + entrypoint: ./test/install_from_local_and_run_code_checks.sh diff --git a/test/Dockerfile_3.11 b/test/Dockerfile_3.11 new file mode 100644 index 0000000..6f693c4 --- /dev/null +++ b/test/Dockerfile_3.11 @@ -0,0 +1,4 @@ +FROM python:3.11 + +RUN pip3 install --upgrade pip +RUN pip3 install pylint mypy diff --git a/test/Dockerfile_3.12 b/test/Dockerfile_3.12 new file mode 100644 index 0000000..4c89c26 --- /dev/null +++ b/test/Dockerfile_3.12 @@ -0,0 +1,4 @@ +FROM python:3.12 + +RUN pip3 install --upgrade pip +RUN pip3 install pylint mypy diff --git a/test/run_code_checks.sh b/test/run_code_checks.sh index bb8068c..1d668bb 100755 --- a/test/run_code_checks.sh +++ b/test/run_code_checks.sh @@ -3,4 +3,4 @@ set -e find undictify -iname "*.py" | grep -v -e "__init__.py" | xargs -L 1 pylint find undictify -iname "*.py" | grep -v -e "__init__.py" | xargs -L 1 mypy --strict -find undictify -iname "*.py" | grep -v -e "__init__.py" | xargs -L 1 python3 -m unittest +python3 -m unittest undictify/tests.py diff --git a/undictify/_unpack.py b/undictify/_unpack.py index 338209d..e71deeb 100644 --- a/undictify/_unpack.py +++ b/undictify/_unpack.py @@ -254,7 +254,7 @@ def _get_value(func: WrappedOrFunc[TypeT], if _is_optional_type(func) or _is_union_type(func) \ else [func])) - if func is inspect.Parameter.empty and param_name != 'self': # type: ignore + if func is inspect.Parameter.empty and param_name != 'self': raise TypeError(f'Parameter {param_name} of target function ' 'is missing a type annotation.') @@ -299,7 +299,7 @@ def _get_value(func: WrappedOrFunc[TypeT], f'into type {_get_type_name(func)} ' f'for key {param_name}.') try: - if isinstance(value, str) and func is bool: # type: ignore + if isinstance(value, str) and func is bool: return _string_to_bool(value) return func(value) except ValueError as ex: @@ -375,7 +375,7 @@ def _is_initvar_type(the_type: Callable[..., TypeT]) -> bool: Therefore, the code below checks for both cases to support 3.7 and 3.8 """ - return the_type == InitVar or isinstance(the_type, InitVar) # type: ignore + return the_type == InitVar or isinstance(the_type, InitVar) def _is_union_type(the_type: Callable[..., TypeT]) -> bool: @@ -416,7 +416,7 @@ def _is_dict_type(the_type: Callable[..., TypeT]) -> bool: def _type_origin_is(the_type: Callable[..., TypeT], origin: Any) -> bool: assert hasattr(the_type, '__origin__') - return the_type.__origin__ is origin # type: ignore + return the_type.__origin__ is origin def _get_union_types(union_type: Callable[..., TypeT]) -> List[Callable[..., TypeT]]: @@ -478,10 +478,8 @@ def _isinstanceofone(value: Callable[..., TypeT], types: List[Callable[..., Type if _isinstanceofone(value, _get_union_types(the_type)): return True try: - # pylint: disable=unidiomatic-typecheck - if type(value) == the_type: # type: ignore + if type(value) == the_type: # pylint: disable=unidiomatic-typecheck return True - # pylint: enable=unidiomatic-typecheck except TypeError: pass return False