|
| 1 | +# flags: --preview --line-length=79 |
| 2 | + |
| 3 | +[a for graph_path_expression in refined_constraint.condition_as_predicate.variables] |
| 4 | +[ |
| 5 | + a |
| 6 | + for graph_path_expression in refined_constraint.condition_as_predicate.variables |
| 7 | +] |
| 8 | +[ |
| 9 | + a |
| 10 | + for graph_path_expression |
| 11 | + in refined_constraint.condition_as_predicate.variables |
| 12 | +] |
| 13 | +[ |
| 14 | + a |
| 15 | + for graph_path_expression in ( |
| 16 | + refined_constraint.condition_as_predicate.variables |
| 17 | + ) |
| 18 | +] |
| 19 | + |
| 20 | +[ |
| 21 | + (foobar_very_long_key, foobar_very_long_value) |
| 22 | + for foobar_very_long_key, foobar_very_long_value in foobar_very_long_dictionary.items() |
| 23 | +] |
| 24 | + |
| 25 | +# Don't split the `in` if it's not too long |
| 26 | +lcomp3 = [ |
| 27 | + element.split("\n", 1)[0] |
| 28 | + for element in collection.select_elements() |
| 29 | + # right |
| 30 | + if element is not None |
| 31 | +] |
| 32 | + |
| 33 | +# Don't remove parens around ternaries |
| 34 | +expected = [i for i in (a if b else c)] |
| 35 | + |
| 36 | +# Nested arrays |
| 37 | +# First in will not be split because it would still be too long |
| 38 | +[[ |
| 39 | + x |
| 40 | + for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
| 41 | + for y in xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 42 | +]] |
| 43 | + |
| 44 | +# Multiple comprehensions, only split the second `in` |
| 45 | +graph_path_expressions_in_local_constraint_refinements = [ |
| 46 | + graph_path_expression |
| 47 | + for refined_constraint in self._local_constraint_refinements.values() |
| 48 | + if refined_constraint is not None |
| 49 | + for graph_path_expression in refined_constraint.condition_as_predicate.variables |
| 50 | +] |
| 51 | + |
| 52 | +# Dictionary comprehensions |
| 53 | +dict_with_really_long_names = { |
| 54 | + really_really_long_key_name: an_even_longer_really_really_long_key_value |
| 55 | + for really_really_long_key_name, an_even_longer_really_really_long_key_value in really_really_really_long_dict_name.items() |
| 56 | +} |
| 57 | +{ |
| 58 | + key_with_super_really_long_name: key_with_super_really_long_name |
| 59 | + for key_with_super_really_long_name in dictionary_with_super_really_long_name |
| 60 | +} |
| 61 | +{ |
| 62 | + key_with_super_really_long_name: key_with_super_really_long_name |
| 63 | + for key_with_super_really_long_name |
| 64 | + in dictionary_with_super_really_long_name |
| 65 | +} |
| 66 | +{ |
| 67 | + key_with_super_really_long_name: key_with_super_really_long_name |
| 68 | + for key in ( |
| 69 | + dictionary |
| 70 | + ) |
| 71 | +} |
| 72 | + |
| 73 | +# output |
| 74 | +[ |
| 75 | + a |
| 76 | + for graph_path_expression in ( |
| 77 | + refined_constraint.condition_as_predicate.variables |
| 78 | + ) |
| 79 | +] |
| 80 | +[ |
| 81 | + a |
| 82 | + for graph_path_expression in ( |
| 83 | + refined_constraint.condition_as_predicate.variables |
| 84 | + ) |
| 85 | +] |
| 86 | +[ |
| 87 | + a |
| 88 | + for graph_path_expression in ( |
| 89 | + refined_constraint.condition_as_predicate.variables |
| 90 | + ) |
| 91 | +] |
| 92 | +[ |
| 93 | + a |
| 94 | + for graph_path_expression in ( |
| 95 | + refined_constraint.condition_as_predicate.variables |
| 96 | + ) |
| 97 | +] |
| 98 | + |
| 99 | +[ |
| 100 | + (foobar_very_long_key, foobar_very_long_value) |
| 101 | + for foobar_very_long_key, foobar_very_long_value in ( |
| 102 | + foobar_very_long_dictionary.items() |
| 103 | + ) |
| 104 | +] |
| 105 | + |
| 106 | +# Don't split the `in` if it's not too long |
| 107 | +lcomp3 = [ |
| 108 | + element.split("\n", 1)[0] |
| 109 | + for element in collection.select_elements() |
| 110 | + # right |
| 111 | + if element is not None |
| 112 | +] |
| 113 | + |
| 114 | +# Don't remove parens around ternaries |
| 115 | +expected = [i for i in (a if b else c)] |
| 116 | + |
| 117 | +# Nested arrays |
| 118 | +# First in will not be split because it would still be too long |
| 119 | +[ |
| 120 | + [ |
| 121 | + x |
| 122 | + for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
| 123 | + for y in ( |
| 124 | + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 125 | + ) |
| 126 | + ] |
| 127 | +] |
| 128 | + |
| 129 | +# Multiple comprehensions, only split the second `in` |
| 130 | +graph_path_expressions_in_local_constraint_refinements = [ |
| 131 | + graph_path_expression |
| 132 | + for refined_constraint in self._local_constraint_refinements.values() |
| 133 | + if refined_constraint is not None |
| 134 | + for graph_path_expression in ( |
| 135 | + refined_constraint.condition_as_predicate.variables |
| 136 | + ) |
| 137 | +] |
| 138 | + |
| 139 | +# Dictionary comprehensions |
| 140 | +dict_with_really_long_names = { |
| 141 | + really_really_long_key_name: an_even_longer_really_really_long_key_value |
| 142 | + for really_really_long_key_name, an_even_longer_really_really_long_key_value in ( |
| 143 | + really_really_really_long_dict_name.items() |
| 144 | + ) |
| 145 | +} |
| 146 | +{ |
| 147 | + key_with_super_really_long_name: key_with_super_really_long_name |
| 148 | + for key_with_super_really_long_name in ( |
| 149 | + dictionary_with_super_really_long_name |
| 150 | + ) |
| 151 | +} |
| 152 | +{ |
| 153 | + key_with_super_really_long_name: key_with_super_really_long_name |
| 154 | + for key_with_super_really_long_name in ( |
| 155 | + dictionary_with_super_really_long_name |
| 156 | + ) |
| 157 | +} |
| 158 | +{ |
| 159 | + key_with_super_really_long_name: key_with_super_really_long_name |
| 160 | + for key in dictionary |
| 161 | +} |
0 commit comments