GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adding type stubs · Issue #448 · msgpack/msgpack-python

Adding type stubs #448

New issue
Copy link
New issue
Copy link
Open
#660
Open
Adding type stubs#448
#660
Copy link

Description

@sbdchd
sbdchd
opened on Dec 11, 2020
Issue body actions

In the course of using msgpack in a project I've written some basic type stubs for the parts of the API I'm using.
I don't think it would be too hard to fill out the type stubs for the rest of the API.

Would you accept a PR adding stub files to the package?
Not sure if you have a preference on adding the types to the code itself or keeping them as separate stub files.

related: https://www.python.org/dev/peps/pep-0561/

Reacted by MapleCCC, Emi, Derek Kulinski, Shahriar Heidrich, austinbutler, Jack McIvor, Neil Girdhar and lovetheguitar

Activity

  1. methane commented on Dec 11, 2020

    @methane
    methane
    on Dec 11, 2020
    Member
    More actions

    Would you accept a PR adding stub files to the package?

    I expect it will be very complex types and very low benefit for users, because msgpack can pack/unpack various types. I don't want to maintain it.

    But if it is simple and very useful, I will consider it.

  2. methane commented on Jan 27, 2021

    @methane
    methane
    on Jan 27, 2021
    Member
    More actions

    See #404.

  3. sbdchd commented on Jan 27, 2021

    @sbdchd
    sbdchd
    on Jan 27, 2021
    Author
    More actions

    I ended up creating a separate type stub package: https://github.com/sbdchd/msgpack-types

    If you aren't interested in have the types in the package itself, would you be okay with me adding them to the type shed?

    https://github.com/python/typeshed/

    Reacted by Emi, Evgeny Markov, Shahriar Heidrich, earonesty, Allan Daemon and jdhao
  4. jfolz commented on Mar 19, 2021

    @jfolz
    jfolz
    on Mar 19, 2021
    Contributor
    More actions

    Well, I know for a fact that this is incorrect. Unpacking methods accept any object that implements the buffer protocol, so next to bytes there's also bytearray, array, memoryview, numpy.ndarray, etc. There is a long-standing issue to add the ability to describe things as "buffer-like". It's an open issue, because buffers are very variable (writeable or not, data types, contiguous or non-contiguous, strided) and you need to describe them pretty accurately so your type annotation is actually useful.

  5. rodrigogiraoserrao commented on Feb 17, 2023

    @rodrigogiraoserrao
    rodrigogiraoserrao
    on Feb 17, 2023
    More actions

    It's been almost 2 years but a comment on the linked issue says PEP 688 is here to save the day.
    Was that the thing that we needed to unblock this?

  6. jfolz commented on Feb 18, 2023

    @jfolz
    jfolz
    on Feb 18, 2023
    Contributor
    More actions

    Well, for one a PEP needs to be accepted and implemented first to make a difference. As of now it's just a draft.

  7. rodrigogiraoserrao commented on Feb 18, 2023

    @rodrigogiraoserrao
    rodrigogiraoserrao
    on Feb 18, 2023
    More actions

    Ugh, sorry. Got so carried away by it that I didn't even check the PEP status.

  8. jfolz commented on Mar 10, 2023

    @jfolz
    jfolz
    on Mar 10, 2023
    Contributor
    More actions

    Good news is that PEP 688 has been accepted. Bad news is that it'll be available in Python 3.12 at the earliest. Any earlier version would need a backport.

    Reacted by Rodrigo Girão Serrão and Shahriar Heidrich
  9. clokep commented on May 30, 2023

    @clokep
    clokep
    on May 30, 2023
    More actions

    Good news is that PEP 688 has been accepted. Bad news is that it'll be available in Python 3.12 at the earliest. Any earlier version would need a backport.

    typing-extensions now supports Buffer in the latest release, this is a common way to backport new typing PEPs to projects.

    Reacted by Shahriar Heidrich, Jack McIvor and Neil Girdhar
  10. rexzhang commented on Mar 6, 2025

    @rexzhang
    rexzhang
    on Mar 6, 2025
    More actions

    Would you accept a PR adding stub files to the package?

    I expect it will be very complex types and very low benefit for users, because msgpack can pack/unpack various types. I don't want to maintain it.

    But if it is simple and very useful, I will consider it.

    The return value of msgpack.packb is bytes, which can reduce many warnings if it is type-annotated.

    Reacted by Allan Daemon and Pea Soft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.