Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format: ensure future keyword import with
in
(#4115)
When a module is formatted that has calls to `internal.member_2` or `internal.member_3`, which get pretty-printed as infix `in` operator calls, the formatter now ensures that the corresponding future keyword import is present. Fixes #4111. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
- Loading branch information
Showing
5 changed files
with
91 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
format/testfiles/test_in_operator_with_all_keywords_import.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package p | ||
|
||
import input.foo | ||
import future.keywords | ||
|
||
r { | ||
internal.member_2(1, [1]) | ||
internal.member_3(0, 1, [1]) | ||
} |
9 changes: 9 additions & 0 deletions
9
format/testfiles/test_in_operator_with_all_keywords_import.rego.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package p | ||
|
||
import future.keywords | ||
import input.foo | ||
|
||
r { | ||
1 in [1] | ||
0, 1 in [1] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package p | ||
|
||
import input.foo | ||
|
||
r { | ||
internal.member_2(1, [1]) | ||
internal.member_3(0, 1, [1]) | ||
} |
9 changes: 9 additions & 0 deletions
9
format/testfiles/test_in_operator_without_import.rego.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package p | ||
|
||
import future.keywords.in | ||
import input.foo | ||
|
||
r { | ||
1 in [1] | ||
0, 1 in [1] | ||
} |