From 93dacfbcae346ebe098b7cb1ba32ea5786f7f4f2 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 24 May 2024 15:11:36 +0530 Subject: [PATCH] Use LoggerProto as type --- faststream/confluent/client.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/faststream/confluent/client.py b/faststream/confluent/client.py index 871a0a9fe7..f1703c3694 100644 --- a/faststream/confluent/client.py +++ b/faststream/confluent/client.py @@ -1,8 +1,8 @@ import asyncio -import logging from ssl import SSLContext from time import time from typing import ( + TYPE_CHECKING, Any, Callable, Dict, @@ -17,10 +17,14 @@ from confluent_kafka import Consumer, KafkaError, KafkaException, Message, Producer from confluent_kafka.admin import AdminClient, NewTopic from pydantic import BaseModel +from typing_extensions import Annotated, Doc from faststream.log import logger from faststream.utils.functions import call_or_await +if TYPE_CHECKING: + from faststream.types import LoggerProto + _missing = object() @@ -106,7 +110,10 @@ def __init__( sasl_kerberos_service_name: str = "kafka", sasl_kerberos_domain_name: Optional[str] = None, sasl_oauth_token_provider: Optional[str] = None, - logger: Optional[logging.Logger] = logger, + logger: Annotated[ + Union["LoggerProto", None, object], + Doc("User specified logger to pass into Context and log service messages."), + ] = logger, ) -> None: self.logger = logger if isinstance(bootstrap_servers, Iterable) and not isinstance( @@ -298,7 +305,10 @@ def __init__( sasl_kerberos_service_name: str = "kafka", sasl_kerberos_domain_name: Optional[str] = None, sasl_oauth_token_provider: Optional[str] = None, - logger: Optional[logging.Logger] = logger, + logger: Annotated[ + Union["LoggerProto", None, object], + Doc("User specified logger to pass into Context and log service messages."), + ] = logger, ) -> None: self.logger = logger if group_id is None: