Skip to content

question: how to type compatibility-only args / kwargs? #1168

Closed

Description

@MarcoGorelli

I'm trying to use pyright --verifytypes to check which public methods are untyped, and a lot of the results come from kwargs and args.

There seem to be 3 cases for them:

  1. they're undocumented, and just silently exist to allow for numpy-compatible code. For example: Series.std
  2. they get passed down to a third-party function. For example: most plotting funtions
  3. when they get passed to other pandas functions which have known args/kwargs. For example, the kwargs in Series.pct_change.

How should kwargs and args get typed in these cases? I'm thinking:
1., 2.: use Any
3.: make a Protocol with only the args/kwargs which can be accepted

I think if we can get these typed (even if just with Any) then pyright's verifytypes should become a lot more useful to identify missing parts of the public API surface

repo where I'm developing this type-coverage-measurement functionality: https://github.com/MarcoGorelli/measuring-pandas-type-completeness (note: it's currently quite patchy, but I've already found it useful to decide what to focus on)

Activity

  1. Dr-Irv commented on Mar 13, 2025

    @Dr-Irv
    Collaborator

    We've used *args: Any, **kwargs: Any, in various places, just not consistently. I'm fine if you want to introduce that.

    In the cases where we know that the possible kwargs are limited (e.g., Series.pct_change(), it would be best to just replace kwargs with the possible keywords that could be used. But as a first pass, we could just let it be **kwargs: Any

  2. added 2 commits that reference this issue on Oct 4, 2025
  3. added a commit that references this issue on Oct 4, 2025
  4. added a commit that references this issue on Aug 28, 2026
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