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

Annotate decorators with ParamSpec #3212

Closed
wants to merge 7 commits into from

Commits on Jan 11, 2022

  1. Annotate decorators with ParamSpec

    This uses `typing.ParamSpec` on `composite`, `functions`, and `given`. This should allow type-checkers and IDEs to infer the signatures of functions returned by these decorators. For `composite` and `functions`, I find this especially helpful.
    gjoseph92 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    0441629 View commit details
    Browse the repository at this point in the history
  2. TypeVar for return type of functions

    Probably won't work, but let's see
    gjoseph92 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    ebf158c View commit details
    Browse the repository at this point in the history
  3. Tests for annotations?

    gjoseph92 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    baa19bf View commit details
    Browse the repository at this point in the history
  4. Single shared ParamSpec P

    gjoseph92 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    fe48210 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3a19cc9 View commit details
    Browse the repository at this point in the history
  6. Remove given annotations—they were wrong

    `given` does consume the function's arguments (obviously), and ParamSpec isn't sophisticated enough to indicate that the _number_ of arguments to `given` is equal to the _number_ of arguments consumed from the wrapped function, even though the types of arguments given to `given` don't match the types of arguments of the function (you'd need to be able to unpack the type argument from the parametrized type somehow).
    
    This was the least important one to annotate anyway IMO.
    gjoseph92 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    4536365 View commit details
    Browse the repository at this point in the history
  7. Remove functions return-type annotation

    python/mypy#3737 is still unfortunate :(
    gjoseph92 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    75472b0 View commit details
    Browse the repository at this point in the history