Skip to content

Wrong signature for KafkaError's 1st parameter in .pyi #2243

Description

The name of the 1st parameter for KafkaError's initialiser in src/confluent_kafka/cimpl.pyi is now code (ref here), however this does not match the underlying code itself.

For example, if we try to create an instance of KafkaError according to the signature:

# kafka_error_test.py

from confluent_kafka import KafkaError

error = KafkaError(code=1)

Then mypy is OK with this

# mypy kafka_error_test.py 
Success: no issues found in 1 source file

But we get a TypeError when it runs

# python kafka_error_test.py 
Traceback (most recent call last):
  File "/workspaces/kafka_error_test.py", line 5, in <module>
    error = KafkaError(code=1)

I'm happy to submit a PR to fix this but which way do we want to go here? Change the signature in the .pyi file so it matches what the underlying C code expects? Or change the underlying C code to match up with the signature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions