summaryrefslogtreecommitdiff
path: root/tests/functional/t/typing_use.py
blob: 68a48d3223a4bc9e0c9f1f0fdb1f38ed00b89fb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# pylint: disable=missing-docstring

import typing
from typing import overload

@typing.overload
def double_with_docstring(arg: str) -> str:
    """Return arg, concatenated with itself."""


@typing.overload
def double_with_docstring(arg: int) -> int:
    """Return twice arg."""


def double_with_docstring(arg):
    """Return 2 * arg."""
    return 2 * arg


def double_with_docstring(arg):  # [function-redefined]
    """Redefined function implementation"""
    return 2 * arg


@typing.overload
def double_with_ellipsis(arg: str) -> str:
    ...


@typing.overload
def double_with_ellipsis(arg: int) -> int:
    ...


def double_with_ellipsis(arg):
    return 2 * arg


@typing.overload
def double_with_pass(arg: str) -> str:
    pass


@typing.overload
def double_with_pass(arg: int) -> int:
    pass


def double_with_pass(arg):
    return 2 * arg

# pylint: disable=too-few-public-methods
class Cls:
    @typing.overload
    def method(self, param: int) -> None:
        ...

    @overload
    def method(self, param: str) -> None:
        ...

    def method(self, param):
        return (self, param)
# pylint: enable=too-few-public-methods