From c77c27a199d44132f9005ce391339db3682d5406 Mon Sep 17 00:00:00 2001 From: Faster Speeding Date: Tue, 3 Jan 2023 10:55:21 +0000 Subject: [PATCH 1/2] Fix Protocol imports on >=3.10 --- src/slotscheck/cli.py | 6 +++++- tests/examples/module_not_ok/foo.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/slotscheck/cli.py b/src/slotscheck/cli.py index 2c38494..bce4f6f 100644 --- a/src/slotscheck/cli.py +++ b/src/slotscheck/cli.py @@ -19,7 +19,6 @@ ) import click -from typing_extensions import Protocol from . import config from .checks import ( @@ -52,6 +51,11 @@ walk_classes, ) +try: + from typing import Protocol +except ImportError: # pragma: no cover + from typing_extensions import Protocol + @click.command("slotscheck") @click.argument( diff --git a/tests/examples/module_not_ok/foo.py b/tests/examples/module_not_ok/foo.py index 8598383..0f93089 100644 --- a/tests/examples/module_not_ok/foo.py +++ b/tests/examples/module_not_ok/foo.py @@ -1,4 +1,8 @@ -from typing_extensions import Protocol + +try: + from typing import Protocol +except ImportError: + from typing_extensions import Protocol class A: From de6697088ea42d709c512178a86691246de5510c Mon Sep 17 00:00:00 2001 From: Arie Bovenberg Date: Tue, 3 Jan 2023 14:07:02 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20Mypy=20fix,=20prepare=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.rst | 6 ++++++ docs/advanced.rst | 2 +- pyproject.toml | 2 +- src/slotscheck/cli.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f167597..ef9347d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Changelog ========= +0.16.3 (2023-01-03) +------------------- + +- Fix broken ``Protocol`` import due to absent ``typing_extensions`` + on Python <3.10. + 0.16.2 (2022-12-29) ------------------- diff --git a/docs/advanced.rst b/docs/advanced.rst index d41af64..4f45f83 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -18,7 +18,7 @@ Use the following configuration: repos: - repo: https://github.com/ariebovenberg/slotscheck - rev: v0.16.2 + rev: v0.16.3 hooks: - id: slotscheck # If your Python files are not importable from the project root, diff --git a/pyproject.toml b/pyproject.toml index 2d85baf..bc52e09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "slotscheck" -version = "0.16.2" +version = "0.16.3" description = "Ensure your __slots__ are working properly." authors = ["Arie Bovenberg "] license = "MIT" diff --git a/src/slotscheck/cli.py b/src/slotscheck/cli.py index bce4f6f..de641d2 100644 --- a/src/slotscheck/cli.py +++ b/src/slotscheck/cli.py @@ -54,7 +54,7 @@ try: from typing import Protocol except ImportError: # pragma: no cover - from typing_extensions import Protocol + from typing_extensions import Protocol # type: ignore[assignment] @click.command("slotscheck")