Skip to content

Let beartype check custom sequence protocol with inner types #277

Answered by leycec
tvdboom asked this question in Q&A
Discussion options

You must be logged in to vote

OMG!!! I can't believe this actually works... but it does. The CPython devs responsible for the standard typing module are very strict and typically try to lock down monkey-patching shenanigans like this. Looks like they forgot to prepare for @beartype:

class SequenceProtocol(Protocol[T]):
    '''
    Type hint factory class dynamically creating and returning new
    ``Annotated[SequenceProtocol[...], ...]`` type hints, subscripted by the
    passed type.

    Parameters
    ----------
    X : object
        Arbitrary child type hint with which to subscript the
        :class:`SequenceProtocol` protocol.

    Returns
    ----------
    Annotated
        ``Annotated[SequenceProtocol[X], ..…

Replies: 8 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@tvdboom
Comment options

Comment options

You must be logged in to vote
3 replies
@tvdboom
Comment options

@leycec
Comment options

@tvdboom
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tvdboom
Comment options

Answer selected by tvdboom
Comment options

You must be logged in to vote
1 reply
@tvdboom
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants