confluent-kafka-python
confluent-kafka-python copied to clipboard
Type hint missing for "from confluent_kafka import Message"
Description
The cimpl
is a binary and IDE can't import definition from it.

How to reproduce
I see that in my VS Code IDE it's an error telling that it can't import the Message
:
from confluent_kafka import Message

Checklist
Please provide the following information:
- [x] confluent-kafka-python and librdkafka version (
confluent_kafka.version() -> ('1.8.2', 17302016)
andconfluent_kafka.libversion() -> ('1.8.2', 17302271)
): - [ ] Apache Kafka broker version:
- [ ] Client configuration:
{...}
- [x] Operating system: Linux
- [ ] Provide client logs (with
'debug': '..'
as necessary) - [ ] Provide broker log excerpts
- [ ] Critical issue
I want to ask, how can I add the type stubs to be able to see the correct imports in the VS Code IDE? Do you provide such a way to import from the binary lib, but have the equal type definitions for such a classes/functions of the confluent_kafka
lib?
Found the reference to config the VS Code IDE, hope it can help: https://stackoverflow.com/a/68887896
Seems like this is a wontfix for now: https://github.com/confluentinc/confluent-kafka-python/issues/1268#issuecomment-1017045748
Seems like this is a wontfix for now: #1268 (comment)
So, do you plan to add stubs? We use Python 3.9 and most of the libs has stubs with type annotations and imports work perfectly. Only I found problems in your library, because it uses partially compiled files and import can't be done there.
I'm not a contributer to this library, just trying to help out with some information 👍
@1st I used mypy's stubgen and then some manual editing based on documentation / librdkafka code reading to add more info to the stubs for my project. It's still a WIP, and a bit of a PITA, but it can get you more type safety, slowly.
i'd love to see type hints and good ide integration.
Hi, it is 2024 and this is the only Python library I use that lacks proper typing support. Are you planning to do something about this?