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
|
# pylint: disable=missing-docstring, bad-whitespace
"""Regression test for https://github.com/PyCQA/pylint/issues/1168
The problem was that we weren't handling keyword-only arguments annotations,
which means we were never processing them.
"""
import re
import typing
from collections import defaultdict
from datetime import datetime
from typing import (
Any,
Callable,
Iterable,
List,
NamedTuple,
Optional,
Pattern,
Sequence,
Set,
Tuple,
)
def func1(arg: Optional[Callable]=None):
return arg
def func2(*, arg: Optional[Iterable]=None):
return arg
SOME_VALUE = [1] # type: List[Any]
for VALUE in [[1], [2], [3]]: # type: Tuple[Any]
print(VALUE)
class ContextManager:
def __enter__(self):
return {1}
def __exit__(self, *_args):
pass
with ContextManager() as SOME_DICT: # type: Set[int]
print(SOME_DICT)
def func_test_type_comment(param):
# type: (NamedTuple) -> Tuple[NamedTuple, Pattern]
return param, re.compile('good')
def typing_fully_qualified():
variable = None # type: typing.Optional[str]
other_variable: 'typing.Optional[str]' = None
return variable, other_variable
def function(arg1, # type: Iterable
arg2 # type: List
):
# type: (...) -> Sequence
"""docstring"""
print(arg1, arg2)
def magic(alpha, beta, gamma):
# type: (str, Optional[str], Optional[datetime]) -> Any
"""going strong"""
return alpha, beta, gamma
def unused_assignment_import():
foo_or_bar = defaultdict(int) # type: defaultdict
return foo_or_bar
|