Skip to content

Commit

Permalink
Merge pull request #134 from FasterSpeeding/bugfix/protocol-imports
Browse files Browse the repository at this point in the history
Fix Protocol imports on >=3.10
  • Loading branch information
ariebovenberg committed Jan 3, 2023
2 parents 309adab + de66970 commit e80825a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
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

0 comments on commit e80825a

Please sign in to comment.