Skip to content

calling .register on typing.KeysView subclass causes false positive error Member "register" is unknown #9296

Closed
@jab

Description

@jab

Type checkers that include the recent changes from #8977 #9058 (e.g. pyright v1.1.281) now incorrectly emit an error like Member "register" is unknown for the following line of code:

https://github.com/jab/bidict/blob/522c9b69249d66c201fed608f95a5da8d3064ed8/bidict/_base.py#L51

Type checkers that do not include those changes (e.g. pyright v1.1.278) do not emit any error for that line, as expected.

Copy/pasted excerpt:

import typing as t

from ._typing import KT  # a typevar


class BidictKeysView(t.KeysView[KT], t.ValuesView[KT]):
    """Since the keys of a bidict are the values of its inverse (and vice versa),
    the :class:`~collections.abc.ValuesView` result of calling *bi.values()*
    is also a :class:`~collections.abc.KeysView` of *bi.inverse*.
    """


dict_keys: t.Type[t.KeysView[t.Any]] = type({}.keys())
BidictKeysView.register(dict_keys)  # <-- false positive error emitted here

Please let me know if there is any other info I can provide. Thank you!

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