Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format skipping (fmt:on/off, autopep8:on/off) only works once #611

Closed
alinsavix opened this issue Sep 26, 2021 · 1 comment
Closed

format skipping (fmt:on/off, autopep8:on/off) only works once #611

alinsavix opened this issue Sep 26, 2021 · 1 comment
Milestone

Comments

@alinsavix
Copy link

For some reason, it looks like the functionality added in #557, to enable blocks of code to be selectively skipped during an autopep8 run, only works if those directives appear a single time in a file. If they appear two or more times, the skip functionality is completely disabled for all instances.

For example, this works as you'd expect:

# fmt: off
test_struct = (
    ("Diffuse",                   "MapObjDiffuse_T1",           "MapObjDiffuse"),
)

test_struct_two = (
    ("TwoLayerDiffuseMod2xNA",    "MapObjDiffuse_Comp",         "MapObjTwoLayerDiffuseMod2xNA"),
)
# fmt: on
$ autopep8 --diff fmt_off_test.py
[no output]

But, if you instead use this input file:

# fmt: off
test_struct = (
    ("Diffuse",                   "MapObjDiffuse_T1",           "MapObjDiffuse"),
)
# fmt: on

# fmt: off
test_struct_two = (
    ("TwoLayerDiffuseMod2xNA",    "MapObjDiffuse_Comp",         "MapObjTwoLayerDiffuseMod2xNA"),
)
# fmt: on

... then both blocks get reformatted:

$ autopep8 --diff fmt_off_test.py
--- original/fmt_off_test.py
+++ fixed/fmt_off_test.py
@@ -1,11 +1,11 @@
 # fmt: off
 test_struct = (
-    ("Diffuse",                          "MapObjDiffuse_T1",           "MapObjD
iffuse"),
+    ("Diffuse", "MapObjDiffuse_T1", "MapObjDiffuse"),
 )
 # fmt: on

 # fmt: off
 test_struct_two = (
-    ("TwoLayerDiffuseMod2xNA",    "MapObjDiffuse_Comp",                "MapObjT
woLayerDiffuseMod2xNA"),
+    ("TwoLayerDiffuseMod2xNA", "MapObjDiffuse_Comp", "MapObjTwoLayerDiffuseMod2
xNA"),
 )
 # fmt: on

This is, needless to say, somewhat problematic when it comes to actually using this feature. (and it would definitely be a nice to use feature, for code that needs large data tables where you want a human to have any hope whatsoever of being able to look at a table be able to understand anything about it)

Environment

  • Python version: 3.9.6
  • autopep8 version: autopep8 1.5.7 (pycodestyle: 2.7.0)
  • Platform: Windows 10 20H2 (build 19042.1202)
@hhatto hhatto added this to the 1.6 milestone Oct 24, 2021
@hhatto
Copy link
Owner

hhatto commented Oct 24, 2021

Thanks for reporting.

duplicate #603.
fixed in version 1.6.

@hhatto hhatto closed this as completed Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants