summaryrefslogtreecommitdiff
path: root/tests/functional/m/missing/missing_kwoa.py
blob: 15df710bfdc1cbe3d1d1bb7a72e80e86c0ab0941 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# pylint: disable=missing-docstring,unused-argument,too-few-public-methods
import contextlib
import typing

def target(pos, *, keyword):
    return pos + keyword


def forwarding_kwds(pos, **kwds):
    target(pos, **kwds)


def forwarding_args(*args, keyword):
    target(*args, keyword=keyword)

def forwarding_conversion(*args, **kwargs):
    target(*args, **dict(kwargs))


def not_forwarding_kwargs(*args, **kwargs):
    target(*args) # [missing-kwoa]


target(1, keyword=2)

PARAM = 1
target(2, PARAM) # [too-many-function-args, missing-kwoa]


def some_function(*, param):
    return param + 2


def other_function(**kwargs):
    return some_function(**kwargs)  # Does not trigger missing-kwoa


other_function(param=2)


class Parent:

    @typing.overload
    def __init__( self, *, first, second, third):
        pass

    @typing.overload
    def __init__(self, *, first, second):
        pass

    @typing.overload
    def __init__(self, *, first):
        pass

    def __init__(
            self,
            *,
            first,
            second: typing.Optional[str] = None,
            third: typing.Optional[str] = None):
        self._first = first
        self._second = second
        self._third = third


class Child(Parent):
    def __init__(
            self,
            *,
            first,
            second):
        super().__init__(first=first, second=second)
        self._first = first + second


@contextlib.contextmanager
def run(*, a):
    yield

def test_context_managers(**kw):
    run(**kw)

    with run(**kw):
        pass

    with run(**kw), run(**kw):
        pass

    with run(**kw), run():  # [missing-kwoa]
        pass

test_context_managers(a=1)