Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ctypes/__init__.pyi uses TypeVar within ClassVar #6333

Description

@erictraut

I just implemented a check in pyright to report an error if a TypeVar is used within a ClassVar declaration. PEP 526 specifically says:

Note that a ClassVar parameter cannot include any type variables, regardless of the level of nesting: ClassVar[T] and ClassVar[List[Set[T]]] are both invalid if T is a type variable.

A similar feature request was recently filed in the mypy issue tracker.

Here's the issue in the pyright issue tracker: microsoft/pyright#2567.

This check is highlighting a problem in the pointer class defined within the ctypes/__init__.pyi stub.

class pointer(Generic[_CT], _PointerLike, _CData):
    _type_: ClassVar[Type[_CT]]

I don't know enough about ctypes to suggest a proper fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions