Skip to content

Commit

Permalink
Merge branch 'bugfixes/typing-__class_getitem__-signature'
Browse files Browse the repository at this point in the history
PR #571
  • Loading branch information
webknjaz committed Dec 15, 2023
2 parents b5ffcd7 + f27d9b9 commit 8348ed3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ comment:
require_changes: true

coverage:
range: 99.09..100
range: 100..100
status:
project:
default:
target: 100%
lib:
paths:
- frozenlist/
target: 97.79%
target: 100%
tests:
paths:
- tests/
Expand Down
1 change: 1 addition & 0 deletions CHANGES/567.bugfix.rst
6 changes: 6 additions & 0 deletions CHANGES/571.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
An incorrect signature of the ``__class_getitem__`` class method
has been fixed, adding a missing ``class_item`` argument under
Python 3.8 and older.

This change also improves the code coverage of this method that
was previously missing -- by :user:`webknjaz`.
7 changes: 5 additions & 2 deletions frozenlist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import types
from collections.abc import MutableSequence
from functools import total_ordering
from typing import Type
from typing import Any, Type

__version__ = "1.4.2.dev0"

Expand All @@ -22,7 +22,10 @@ class FrozenList(MutableSequence):
else:

@classmethod
def __class_getitem__(cls: Type["FrozenList"]) -> Type["FrozenList"]:
def __class_getitem__(
cls: Type["FrozenList"],
cls_item: Any,
) -> Type["FrozenList"]:
return cls

def __init__(self, items=None):
Expand Down
2 changes: 1 addition & 1 deletion frozenlist/_frozenlist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cdef class FrozenList:
__class_getitem__ = classmethod(types.GenericAlias)
else:
@classmethod
def __class_getitem__(cls):
def __class_getitem__(cls, cls_item):
return cls

cdef readonly bint frozen
Expand Down
3 changes: 3 additions & 0 deletions tests/test_frozenlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class FrozenListMixin:

SKIP_METHODS = {"__abstractmethods__", "__slots__"}

def test___class_getitem__(self) -> None:
assert self.FrozenList[str] is not None

def test_subclass(self) -> None:
assert issubclass(self.FrozenList, MutableSequence)

Expand Down

0 comments on commit 8348ed3

Please sign in to comment.