Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bytes broader than bytearray? #8970

Closed as not planned
Closed as not planned
@gsakkis

Description

@gsakkis

Mypy errors with Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [misc] for the following class:

from typing import Optional, Union, overload


class Transform:
    @overload
    def apply(self, b: bytes) -> bytes:
        """Return the transformed bytestring of the input"""

    @overload
    def apply(self, b: bytearray) -> None:
        """Transform the input bytearray in place"""

    def apply(self, b: Union[bytes, bytearray]) -> Optional[bytes]:
        pass

Changing the order of the two @overload doesn't give the error.

mypy --version
mypy 0.981 (compiled: yes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions