-
Notifications
You must be signed in to change notification settings - Fork 382
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
Typings #1163
Typings #1163
Conversation
# Will be implemented differently in child classes, but define here for static analysis | ||
pass | ||
|
||
@classmethod | ||
def create_from_connection_string(cls, connection_string, **kwargs): | ||
def create_from_connection_string(cls, connection_string: str, **kwargs: Dict[str, Any]) -> Self: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't annotate the kwargs. Here and everywhere.
""" | ||
Read-only property to indicate if the transport is connected or not. | ||
""" | ||
return self._mqtt_pipeline.connected | ||
|
||
@property | ||
def on_connection_state_change(self): | ||
def on_connection_state_change(self) -> Callable[[Any], Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat surprised this passes static analysis, although I suppose that's due to only annotating the surface.
The issue is that this is too broad. It says you can set any callable that takes any number of arguments and returns any type of value. This is not true, and following this annotation would produce errors.
This should probably be FunctionOrCoroutine[[None], None], however, I'm not quite sure if that is valid for all versions of Python - it used to not be due to a bug, but I believe that has been fixed since I reported it? If it hasn't been, I can live with Callable[[Any], Any], but it's problematic.
Here and everywhere obviously (although the specific type annotations would change with handler definition)
No description provided.