Skip to content
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

Enhanced typing of subscribe() #847

Merged
merged 8 commits into from Apr 25, 2024

Commits on Mar 1, 2024

  1. Enhanced typing of subscribe()

    This PR adds type var `T_Event` and uses it to type the `subscribe()` interfaces.
    
    Fixes an issue where subscribing a handler would raise a type error if the handler is typed to receive a subclass of `Event`.
    
    Allows type checkers to verify that the handler passed to `subscribe()` can support the event types it is assigned to handle.
    
    Closes agronholm#846
    peterschutt committed Mar 1, 2024
    Copy the full SHA
    fffec7b View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    5dab277 View commit details
    Browse the repository at this point in the history
  3. Handle paho-mqtt v1/v2 compat.

    Relaxes the signatures of methods on `MQTTEventBroker` that are registered as callbacks on the mqtt client so that they will work as either v1 or v2 client style callbacks.
    
    Adds a tox env to explicitly test against paho-mqtt v1 (`$ tox -e paho-mqtt-v1`).
    peterschutt committed Mar 1, 2024
    Copy the full SHA
    a3dfa99 View commit details
    Browse the repository at this point in the history
  4. Change to @overload approach.

    This commit keeps the behavior of the subscribe methods as they are for the case where a subscription is added for an iterable of event types. However, for the case where a subscription is added for a single event type, it allows the callable to be typed to receive an instance of that event type, removing the need to type-narrow in that case.
    peterschutt committed Mar 1, 2024
    Copy the full SHA
    b4db236 View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2024

  1. Copy the full SHA
    d22ef3a View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    3ef79bb View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2024

  1. Copy the full SHA
    50031f0 View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2024

  1. Copy the full SHA
    9207f3e View commit details
    Browse the repository at this point in the history