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

various cleanups for typing stuff #19270

Merged

Commits on Jan 30, 2024

  1. test/static-code: add partial mypy --strict mode

    Start building a list of files in src/cockpit which are clean under
    `mypy --strict` to ensure that we don't regress.  The end goal is to
    have all of `src/cockpit` strictly typed.
    allisonkarlitskaya committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    b2e465d View commit details
    Browse the repository at this point in the history
  2. protocol: remove all talk of memoryview

    At one point we wanted to implement this as a BufferedProtocol, where a
    memoryview would have likely been advantageous.  We went with our
    current "dumb" bytes-based approach instead, and haven't found any
    egregious performance problems there, so let's remove the code that
    could theoretically deal with memoryview.  Maybe we'll do something more
    intelligent at some point in the future.
    
    We also lift a check on the value being non-empty to the loop in the
    calling function.  This is not strictly required, but speeds things up
    in the EOF case.
    allisonkarlitskaya committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    2542bf0 View commit details
    Browse the repository at this point in the history
  3. protocol: add better typing hints

    This file is now clean under `mypy --strict`.
    allisonkarlitskaya committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    848aade View commit details
    Browse the repository at this point in the history
  4. bridge: clean up kill message forwarding

    Since 747e7c2 we have the ability to
    send verbatim JSON objects as control messages, which we do when
    forwarding channel control messages to peers.  Until now, we haven't
    applied the same handling for 'kill' messages because we haven't had
    access to the message object in order to be able to forward it.
    
    This means that we've been unintentionally breaking protocol: the
    current way we construct the control message from kwargs, we always send
    up sending both "host" and "group", even if one of them is `null`, which
    is a violation of protocol (these should either be strings, or absent).
    
    Let's wire the original message through and send it verbatim: this will
    help us in the next commit when we start enforcing type safety on kill
    message parameters.
    allisonkarlitskaya committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    581c66b View commit details
    Browse the repository at this point in the history
  5. protocol: use JSON helpers for control messages

    Drop the manual error checking on 'init' messages and avoid the total
    lack of error checking for 'kill' and 'authorize' messages.
    allisonkarlitskaya committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    4d1f268 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d4bfd9a View commit details
    Browse the repository at this point in the history