Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Protocol imports on >=3.10 #134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions 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)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced.rst
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion 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 <a.c.bovenberg@gmail.com>"]
license = "MIT"
Expand Down
6 changes: 5 additions & 1 deletion src/slotscheck/cli.py
Expand Up @@ -19,7 +19,6 @@
)

import click
from typing_extensions import Protocol

from . import config
from .checks import (
Expand Down Expand Up @@ -52,6 +51,11 @@
walk_classes,
)

try:
from typing import Protocol
except ImportError: # pragma: no cover
from typing_extensions import Protocol # type: ignore[assignment]


@click.command("slotscheck")
@click.argument(
Expand Down
6 changes: 5 additions & 1 deletion 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:
Expand Down