aboutsummaryrefslogtreecommitdiff
path: root/test/formatters
diff options
context:
space:
mode:
Diffstat (limited to 'test/formatters')
-rw-r--r--test/formatters/installers/snakefmt.bash2
-rw-r--r--test/formatters/samplecode/snakefmt/in.smk21
-rw-r--r--test/formatters/samplecode/snakefmt/out.smk44
3 files changed, 67 insertions, 0 deletions
diff --git a/test/formatters/installers/snakefmt.bash b/test/formatters/installers/snakefmt.bash
new file mode 100644
index 0000000..003234d
--- /dev/null
+++ b/test/formatters/installers/snakefmt.bash
@@ -0,0 +1,2 @@
+apt-get install -y python3-pip
+pip install snakefmt
diff --git a/test/formatters/samplecode/snakefmt/in.smk b/test/formatters/samplecode/snakefmt/in.smk
new file mode 100644
index 0000000..10adc3c
--- /dev/null
+++ b/test/formatters/samplecode/snakefmt/in.smk
@@ -0,0 +1,21 @@
+from snakemake.utils import min_version
+min_version("5.14.0")
+configfile: "config.yaml" # snakemake keywords are treated like classes i.e. 2 newlines
+SAMPLES = ['s1', 's2'] # strings are normalised
+CONDITIONS = ["a", "b", "longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglong"] # long lines are wrapped
+include: "rules/foo.smk" # 2 newlines
+
+rule all:
+ input: "data/results.txt" # newlines after keywords enforced and trailing comma
+
+rule gets_separated_by_two_newlines:
+ input:
+ files = expand("long/string/to/data/files/gets_broken_by_black/{sample}.{condition}",sample=SAMPLES, condition=CONDITIONS)
+if True:
+ rule can_be_inside_python_code:
+ input: "parameters", "get_indented"
+ threads: 4 # Numeric params stay unindented
+ params: key_val = "PEP8_formatted"
+ run:
+
+ print("weirdly_spaced_string_gets_respaced")
diff --git a/test/formatters/samplecode/snakefmt/out.smk b/test/formatters/samplecode/snakefmt/out.smk
new file mode 100644
index 0000000..049f04c
--- /dev/null
+++ b/test/formatters/samplecode/snakefmt/out.smk
@@ -0,0 +1,44 @@
+from snakemake.utils import min_version
+
+min_version("5.14.0")
+
+
+configfile: "config.yaml" # snakemake keywords are treated like classes i.e. 2 newlines
+
+
+SAMPLES = ["s1", "s2"] # strings are normalised
+CONDITIONS = [
+ "a",
+ "b",
+ "longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglong",
+] # long lines are wrapped
+
+
+include: "rules/foo.smk" # 2 newlines
+
+
+rule all:
+ input:
+ "data/results.txt", # newlines after keywords enforced and trailing comma
+
+
+rule gets_separated_by_two_newlines:
+ input:
+ files=expand(
+ "long/string/to/data/files/gets_broken_by_black/{sample}.{condition}",
+ sample=SAMPLES,
+ condition=CONDITIONS,
+ ),
+
+
+if True:
+
+ rule can_be_inside_python_code:
+ input:
+ "parameters",
+ "get_indented",
+ threads: 4 # Numeric params stay unindented
+ params:
+ key_val="PEP8_formatted",
+ run:
+ print("weirdly_spaced_string_gets_respaced")