fix: correct logger type from logging.Handler to logging.Logger#2209
Open
Turan Almammadov (turanalmammadov) wants to merge 1 commit intoconfluentinc:masterfrom
Open
fix: correct logger type from logging.Handler to logging.Logger#2209Turan Almammadov (turanalmammadov) wants to merge 1 commit intoconfluentinc:masterfrom
Turan Almammadov (turanalmammadov) wants to merge 1 commit intoconfluentinc:masterfrom
Conversation
The documentation incorrectly stated that the `logger` keyword argument accepts a `logging.Handler` instance. The C implementation calls `logger.log(level, msg, *args)`, which is a `logging.Logger` method, not a method on `logging.Handler`. - Update docs/index.rst to reference `logging.Logger` instead of `logging.Handler`, and add a note clarifying the internal call pattern. - Add `import logging` to cimpl.pyi and explicitly type the `logger` parameter as `Optional[logging.Logger]` in the `Producer` and `Consumer` constructor overloads so IDEs and type-checkers can surface the correct type. Fixes confluentinc#1668 Made-with: Cursor
|
Please sign the Contributor License Agreement here before this PR can be approved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #1668
The documentation in
docs/index.rst(and the corresponding online Kafka Client Configuration reference) documents theloggerkeyword argument as accepting alogging.Handlerinstance:However, the C implementation in
src/confluent_kafka/src/confluent_kafka.ccalls:This is calling
.log(level, msg, *args), which is a method onlogging.Logger— notlogging.Handler.logging.Handlerexposes.emit(record), not.log(...).The existing example code in the docs already uses
logging.getLogger()(which returns aLogger), confirming the docs description was wrong.Changes
docs/index.rst: Changedlogging.Handler→logging.Loggerin theloggerkwarg description. Added a clarifying note about the internal.log(level, msg, *args)call pattern.src/confluent_kafka/cimpl.pyi: Addedimport loggingand explicitly typed theloggerparameter asOptional[logging.Logger]in theProducerandConsumerconstructor overloads. This makes IDEs and type checkers surface the correct type rather than acceptingAnyvia**kwargs.Testing
The fix is documentation/type-stub only — no behavioral change. The existing examples in the docs already demonstrate the correct usage.
Made with Cursor