diff --git a/optype/__init__.py b/optype/__init__.py index 323fbfc4..cb5829ae 100644 --- a/optype/__init__.py +++ b/optype/__init__.py @@ -15,7 +15,6 @@ 'CanCeil', 'CanComplex', 'CanContains', - 'CanDel', 'CanDelattr', 'CanDelete', 'CanDelitem', @@ -30,7 +29,6 @@ 'CanFormat', 'CanGe', 'CanGet', - 'CanGetBound', 'CanGetattr', 'CanGetattribute', 'CanGetitem', @@ -50,7 +48,6 @@ 'CanITruediv', 'CanIXor', 'CanIndex', - 'CanInitSubclass', 'CanInt', 'CanInvert', 'CanIter', @@ -103,15 +100,20 @@ 'CanWith', 'CanXor', 'HasAnnotations', + 'HasClass', + 'HasCode', 'HasDict', 'HasDoc', + 'HasFunc', 'HasMatchArgs', 'HasModule', 'HasName', + 'HasNames', 'HasQualname', - 'HasWeakCallableProxy', - 'HasWeakProxy', - 'HasWeakReference', + 'HasSelf', + 'HasSlots', + 'HasTypeParams', + 'HasWrapped', '__version__', ) @@ -134,7 +136,6 @@ CanCeil, CanComplex, CanContains, - CanDel, CanDelattr, CanDelete, CanDelitem, @@ -149,7 +150,6 @@ CanFormat, CanGe, CanGet, - CanGetBound, CanGetattr, CanGetattribute, CanGetitem, @@ -169,7 +169,6 @@ CanITruediv, CanIXor, CanIndex, - CanInitSubclass, CanInt, CanInvert, CanIter, @@ -224,15 +223,20 @@ ) from ._has import ( HasAnnotations, + HasClass, + HasCode, HasDict, HasDoc, + HasFunc, HasMatchArgs, HasModule, HasName, + HasNames, HasQualname, - HasWeakCallableProxy, - HasWeakProxy, - HasWeakReference, + HasSelf, + HasSlots, + HasTypeParams, + HasWrapped, ) diff --git a/optype/_can.py b/optype/_can.py index f0e535d7..1344191d 100644 --- a/optype/_can.py +++ b/optype/_can.py @@ -1,13 +1,7 @@ # ruff: noqa: PYI034 -from collections.abc import Generator +from collections.abc import Generator # sadge :( from types import TracebackType -from typing import ( - Any, - Protocol, - overload, - override, - runtime_checkable, -) +from typing import Any, Protocol, overload, override, runtime_checkable # Iterator types @@ -25,12 +19,9 @@ def __iter__(self) -> Vs: ... # 3.3.1. Basic customization # https://docs.python.org/3/reference/datamodel.html#basic-customization -# TODO: __new__ -# TODO: __init__ - -@runtime_checkable -class CanDel(Protocol): - def __del__(self) -> Any: ... +# @runtime_checkable +# class CanDel(Protocol): +# def __del__(self) -> Any: ... @runtime_checkable class CanRepr[Y: str](Protocol): @@ -146,16 +137,16 @@ def __delete__(self, __obj: T) -> Any: ... # 3.3.3. Customizing class creation # https://docs.python.org/3/reference/datamodel.html#customizing-class-creation -@runtime_checkable -class CanInitSubclass[**Ps](Protocol): - # no positional-only are allowed - # cannot `Unpack` type args: https://github.com/python/typing/issues/1399 - # workaround: use `**Ps` instead of `Ps: TypedDict` - def __init_subclass__( - cls, - *__dont_use_these_args: Ps.args, - **__kwargs: Ps.kwargs, - ) -> Any: ... +# @runtime_checkable +# class CanInitSubclass[**Ps](Protocol): +# # no positional-only are allowed +# # cannot `Unpack` type args: https://github.com/python/typing/issues/1399 +# # workaround: use `**Ps` instead of `Ps: TypedDict` +# def __init_subclass__( +# cls, +# *__dont_use_these_args: Ps.args, +# **__kwargs: Ps.kwargs, +# ) -> Any: ... @runtime_checkable class CanSetName[T](Protocol): @@ -587,7 +578,7 @@ class CanAsyncWith[V, R](CanAenter[V], CanAexit[R], Protocol): # Module `abc` # https://docs.python.org/3/library/abc.html -# TODO: CanSubclasshook +# TODO: CanSubclasshook? # Module `copy`