Skip to content

confusing formatting on overloads in vendored stubs #2945

@DetachHead

Description

@DetachHead

Summary

there seems to be an additional newline between overloads, but not between different functions. this makes it look like the functions are grouped together but not by overload, which makes it kinda difficult to read.

example from re.pyi:

@overload
def compile(pattern: AnyStr, flags: _FlagsType = 0) -> Pattern[AnyStr]:
    """Compile a regular expression pattern, returning a Pattern object."""

@overload
def compile(pattern: Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ...
@overload
def search(pattern: str | Pattern[str], string: str, flags: _FlagsType = 0) -> Match[str] | None:
    """Scan through string looking for a match to the pattern, returning
    a Match object, or None if no match was found.
    """

@overload
def search(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = 0) -> Match[bytes] | None: ...
@overload
def match(pattern: str | Pattern[str], string: str, flags: _FlagsType = 0) -> Match[str] | None:
    """Try to apply the pattern at the start of the string, returning
    a Match object, or None if no match was found.
    """

@overload
def match(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = 0) -> Match[bytes] | None: ...
@overload
def fullmatch(pattern: str | Pattern[str], string: str, flags: _FlagsType = 0) -> Match[str] | None:
    """Try to apply the pattern to all of the string, returning
    a Match object, or None if no match was found.
    """

@overload
def fullmatch(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = 0) -> Match[bytes] | None: ...
@overload
def split(pattern: str | Pattern[str], string: str, maxsplit: int = 0, flags: _FlagsType = 0) -> list[str | MaybeNone]:
    """Split the source string by the occurrences of the pattern,
    returning a list containing the resulting substrings.  If
    capturing parentheses are used in pattern, then the text of all
    groups in the pattern are also returned as part of the resulting
    list.  If maxsplit is nonzero, at most maxsplit splits occur,
    and the remainder of the string is returned as the final element
    of the list.
    """

@overload
def split(
    pattern: bytes | Pattern[bytes], string: ReadableBuffer, maxsplit: int = 0, flags: _FlagsType = 0
) -> list[bytes | MaybeNone]: ...

Version

0.0.20

Metadata

Metadata

Assignees

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