Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partially unknown types in pyright #1697

Open
khusmann opened this issue Dec 15, 2024 · 2 comments
Open

partially unknown types in pyright #1697

khusmann opened this issue Dec 15, 2024 · 2 comments

Comments

@khusmann
Copy link

  • bleak version: 0.22.1
  • Python version: 3.10
  • pylance version: v2024.7.1

Description

In commands that make use of *kwargs, pyright complains that types are unknown

What I Did

For example, on BleakClient.connect()

image

Type of "connect" is partially unknown
  Type of "connect" is "(**kwargs: Unknown) -> Coroutine[Any, Any, bool]"Pylance[reportUnknownMemberType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUnknownMemberType)

Type errors are resolved if we change

async def connect(self, **kwargs) -> bool:

to

async def connect(self, **kwargs: Any) -> bool:

it looks like this should be done to all *args and **kwargs across all functions.

Or perhaps we should do something with Unpack[] like BleakScanner does for a few of its methods?

cls, device_identifier: str, timeout: float = 10.0, **kwargs: Unpack[ExtraArgs]

@dlech
Copy link
Collaborator

dlech commented Dec 15, 2024

Using Unpack sounds like the best option to me.

@khusmann
Copy link
Author

Yeah I wasn't familiar with Unpack until happened to see it here, but looks like the Right Way™ to go about this.

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

No branches or pull requests

2 participants