-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Workaround for 'Shadows built-in name
input
' inspection on lam…
…bda parameters, see #133
- Loading branch information
Showing
5 changed files
with
99 additions
and
9 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
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
19 changes: 11 additions & 8 deletions
19
src/main/kotlin/com/jetbrains/snakecharm/lang/highlighter/SnakemakeVisitorFilter.kt
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
33 changes: 33 additions & 0 deletions
33
src/test/resources/features/highlighting/inspections/py_shadowing_builtins.feature
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,33 @@ | ||
Feature: Fixes PyShadowingBuiltinsInspection related false positives | ||
Issue #133 | ||
|
||
@ignore("Is disabled dut to a workaround for #133") | ||
Scenario: PyShadowingBuiltinsInspection works in snakemake files | ||
Given a snakemake project | ||
Given I open a file "foo.smk" with text | ||
""" | ||
input = 1 | ||
""" | ||
And PyShadowingBuiltinsInspection inspection is enabled | ||
Then I expect inspection weak warning on <input> with message | ||
""" | ||
Shadows built-in name 'input' | ||
""" | ||
When I check highlighting weak warnings | ||
|
||
Scenario Outline: Lambda params do not shadow builtin names | ||
Given a snakemake project | ||
Given I open a file "foo.smk" with text | ||
""" | ||
<rule_like> rule_133: | ||
input: "in" | ||
params: | ||
methylomes2=lambda wildcards, input: "", | ||
""" | ||
And PyShadowingBuiltinsInspection inspection is enabled | ||
Then I expect no inspection weak warnings | ||
When I check highlighting weak warnings | ||
Examples: | ||
| rule_like | | ||
| rule | | ||
| checkpoint | |
50 changes: 50 additions & 0 deletions
50
src/test/resources/features/highlighting/inspections/py_shadowing_names.feature
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,50 @@ | ||
Feature: Fixes PyShadowingNamesInspection related false positives | ||
Issue #133 | ||
|
||
Scenario: PyShadowingNamesInspection works in snakemake files | ||
Given a snakemake project | ||
Given I open a file "foo.smk" with text | ||
""" | ||
resources = 1 | ||
wd = 1 | ||
rule rule_133: | ||
input: "in" | ||
output: "out.txt" | ||
threads: 5 | ||
params: | ||
methylomes3=lambda wd, resources: "", | ||
""" | ||
And PyShadowingNamesInspection inspection is enabled | ||
# warning only for resources and wd because they == 1, not for input, output, threads | ||
Then I expect inspection weak warning on <wd> in <wd,> with message | ||
""" | ||
Shadows name 'wd' from outer scope | ||
""" | ||
Then I expect inspection weak warning on <resources> in <resources:> with message | ||
""" | ||
Shadows name 'resources' from outer scope | ||
""" | ||
|
||
When I check highlighting weak warnings | ||
|
||
Scenario Outline: Lambda params do not shadow section names | ||
Given a snakemake project | ||
Given I open a file "foo.smk" with text | ||
""" | ||
<rule_like> rule_133: | ||
input: "in" | ||
output: "out.txt" | ||
threads: 5 | ||
params: | ||
methylomes1=lambda wildcards, output: "", | ||
methylomes2=lambda wildcards, input: "", | ||
methylomes3=lambda wildcards, resources: "", | ||
methylomes4=lambda wildcards, threads: "" | ||
""" | ||
And PyShadowingNamesInspection inspection is enabled | ||
Then I expect no inspection weak warnings | ||
When I check highlighting weak warnings | ||
Examples: | ||
| rule_like | | ||
| rule | | ||
| checkpoint | |