Debian Codegraph @

tests/data/cases/comments_in_blocks.py

raw
1 # Test cases from:
2 # - https://github.com/psf/black/issues/1798
3 # - https://github.com/psf/black/issues/1499
4 # - https://github.com/psf/black/issues/1211
5 # - https://github.com/psf/black/issues/563
6
7 (
8 lambda
9 # a comment
10 : None
11 )
12
13 (
14 lambda:
15 # b comment
16 None
17 )
18
19 (
20 lambda
21 # a comment
22 :
23 # b comment
24 None
25 )
26
27 [
28 x
29 # Let's do this
30 for
31 # OK?
32 x
33 # Some comment
34 # And another
35 in
36 # One more
37 y
38 ]
39
40 return [
41 (offers[offer_index], 1.0)
42 for offer_index, _
43 # avoid returning any offers that don't match the grammar so
44 # that the return values here are consistent with what would be
45 # returned in AcceptValidHeader
46 in self._parse_and_normalize_offers(offers)
47 ]
48
49 from foo import (
50 bar,
51 # qux
52 )
53
54
55 def convert(collection):
56 # replace all variables by integers
57 replacement_dict = {
58 variable: f"{index}"
59 for index, variable
60 # 0 is reserved as line terminator
61 in enumerate(collection.variables(), start=1)
62 }
63
64
65 {
66 i: i
67 for i
68 # a comment
69 in range(5)
70 }
71
72
73 def get_subtree_proof_nodes(
74 chunk_index_groups: Sequence[Tuple[int, ...], ...],
75 ) -> Tuple[int, ...]:
76 subtree_node_paths = (
77 # We take a candidate element from each group and shift it to
78 # remove the bits that are not common to other group members, then
79 # we convert it to a tree path that all elements from this group
80 # have in common.
81 chunk_index
82 for chunk_index, bits_to_truncate
83 # Each group will contain an even "power-of-two" number of# elements.
84 # This tells us how many tailing bits each element has# which need to
85 # be truncated to get the group's common prefix.
86 in ((group[0], (len(group) - 1).bit_length()) for group in chunk_index_groups)
87 )
88 return subtree_node_paths
89
90
91 if (
92 # comment1
93 a
94 # comment2
95 or (
96 # comment3
97 (
98 # comment4
99 b
100 )
101 # comment5
102 and
103 # comment6
104 c
105 or (
106 # comment7
107 d
108 )
109 )
110 ):
111 print("Foo")