snakefmt icon indicating copy to clipboard operation
snakefmt copied to clipboard

Decorated functions lead to error

Open holtgrewe opened this issue 3 years ago • 4 comments
trafficstars

import contextlib

@contextlib.contextmanager
def some_helper():
    pass

produces

snakefmt.exceptions.InvalidPython: Got error:

Cannot parse: 41:1: @

while formatting code with black.

holtgrewe avatar Mar 24 '22 13:03 holtgrewe

Hi @holtgrewe I can't seem to replicate this with the latest snakefmt (v0.6.0)

$ singularity exec "docker://quay.io/biocontainers/snakefmt:0.6.0--pyhdfd78af_0" snakefmt --diff - << '@'
import contextlib

@contextlib.contextmanager
def some_helper():
    pass
@
=====> Diff for stdin <=====

  import contextlib
+

  @contextlib.contextmanager
  def some_helper():
      pass

[INFO] All done 🎉

mbhall88 avatar Mar 25 '22 00:03 mbhall88

Sorry, the following MWE is better.

# singularity exec "docker://quay.io/biocontainers/snakefmt:0.6.0--pyhdfd78af_0" snakefmt --diff - << '@'
rule run_varfish_annotator:
    run:
        print("")


@contextlib.contextmanager
def tmp_with_varfishrc(wildcards):
    pass
@
INFO:    Using cached SIF image
snakefmt.exceptions.InvalidPython: Got error:

Cannot parse: 4:1: @

while formatting code with black.

holtgrewe avatar Mar 25 '22 07:03 holtgrewe

Thanks @holtgrewe I can recreate now.

We'll take a look at this after #136 is finished

mbhall88 avatar Apr 06 '22 22:04 mbhall88

@mbhall88 i'll give that review a go in the next week or so

bricoletc avatar Apr 07 '22 08:04 bricoletc