Skip to content

stubgen: combine --include-docstrings and typeshed #17200

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

Open
mikez opened this issue Apr 30, 2024 · 0 comments
Open

stubgen: combine --include-docstrings and typeshed #17200

mikez opened this issue Apr 30, 2024 · 0 comments
Labels

Comments

@mikez
Copy link

mikez commented Apr 30, 2024

Feature

Run stubgen --include-docstrings -p $STDLIB_PACKAGE --typeshed (?) or some other way and have it generate a stub that has the same syntax as the typeshed with docstrings included.

Pitch

Right now, stubgen --include-docstrings -p builtins generates

class str:
    …
    def strip(self, *args, **kwargs):
        """Return a copy of the string with leading and trailing whitespace removed.

        If chars is given and not None, remove characters in chars instead."""

whereas using the typeshed annotations it might instead look like

class str(Sequence[str]):
    …
    @overload
    def strip(self: LiteralString, chars: LiteralString | None = None, /) -> LiteralString:
        """Return a copy of the string with leading and trailing whitespace removed.

        If chars is given and not None, remove characters in chars instead."""

    @overload
    def strip(self, chars: str | None = None, /) -> str:  # type: ignore[misc]
        """Return a copy of the string with leading and trailing whitespace removed.

        If chars is given and not None, remove characters in chars instead."""

Apologies
I'm new to the mypy project, so please feel to close this if it is out of scope or if I have misunderstood your aim with stubgen. My particular use case is using this in pyright to get proper stdlib stub docstrings; it imports these from typeshed whose stubs don't include docstrings. (See typeshed discussion here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant