File: err_173.py

package info (click to toggle)
python-refurb 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,700 kB
  • sloc: python: 9,468; makefile: 40; sh: 6
file content (76 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download
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
x = {"a": 1}
y = {"b": 2}
z = {"c": 3}

# these should match

_ = {**x, **y}
_ = {**x, "b": 2}
_ = {**x, "b": 2, "c": 3}
_ = {"a": 1, **x}
_ = {"a": 1, "b": 2, **x}
_ = {"a": 1, **x, **y}
_ = {**x, **y, "c": 3}
_ = {**x, **y, **z}
_ = {**x, **y, **z, **x}
_ = {**x, **y, **z, **x, **x}
_ = {**x, **y, **z, **x, "a": 1}

from collections import ChainMap, Counter, OrderedDict, defaultdict, UserDict

chainmap = ChainMap()
_ = {"k": "v", **chainmap}

counter = Counter()
_ = {"k": "v", **counter}

ordereddict = OrderedDict()
_ = {"k": "v", **ordereddict}

dd = defaultdict()
_ = {"k": "v", **dd}

userdict = UserDict()
_ = {"k": "v", **userdict}


_ = dict(**x)
_ = dict(x, **y)
_ = dict(**x, **y)
_ = dict(x, a=1)
_ = dict(**x, a=1, b=2)
_ = dict(**x, **y, a=1, b=2)


# these should not

_ = {}
_ = {**x}
_ = {**x, "a": 1, **y}
_ = {"a": 1}
_ = {"a": 1, "b": 2}
_ = {"a": 1, **x, "b": 2}


class C:
    from typing import Any

    def keys(self):
        return []

    def __getitem__(self, key: str) -> Any:
        pass


c = C()

_ = {"k": "v", **c}

# TODO: support more expr types
_ = {"k": "v", **{}}


_ = dict(x)  # noqa: FURB123
_ = dict(*({},))
_ = dict()  # noqa: FURB112
_ = dict(a=1, b=2)