# fmt: pass - ignore formatting for single statements
See original GitHub issueFeature request:
# fmt: pass
would skip formatting for the single statement that immediately follows.
Is your feature request related to a problem? Please describe.
Not a response to a problem but it might be helpful for the following reasons:
- Easier to use / less typing
- Can’t forget to turn it back on
- Or accidentally insert code you do want formatted into an unformatted block
- Encourages ignoring less code
- One-offs are always isolated to one statement instead of potentially large chunks of code.
Describe the solution you’d like
z = "hello " + "world"
# fmt: pass
custom_formatting = [
0, 1, 2,
3, 4, 5,
6, 7, 8,
]
regular_formatting = [
0, 1, 2, 'this will be formatted'
]
The custom_formatting
list would be ignored, everything else would be formatted.
Describe alternatives you’ve considered
- Current solution
# fmt: off
ugly_code=('but I want it this way')
even_more=('dont\'t judge me')
# fmt: on
#fmt: off
at end of line (#790) I believe# fmt: pass
addresses the same concern while also being a bit more flexible.- a single statement could be multi-line
- a long line would bury an inline comment
# fmt: pass
is more readable & predictable as a separate line
- Disable formatting for certain expressions only. #798
- Deal with it
Additional context
Naming:
-
# fmt: pass
reflects Python’s existing pass statement. Hopefully this hints that you can use it to temporarily appease the formatter for one quick thing, but it’s not something you want everywhere. -
Naming could be anything, e.g. “pass”, “skip”, “ignore”
Issue Analytics
- State:
- Created 4 years ago
- Reactions:23
- Comments:5 (1 by maintainers)
Top Results From Across the Web
{fmt}: Will a named argument be ignored if it doesn't exist in ...
This is by design. Unused formatting arguments are essentially the same as unused arguments to any other function and are not an error....
Read more >The Black code style - Black 22.12.0 documentation
How Black wraps lines# ... Black ignores previous formatting and applies uniform horizontal and vertical whitespace to your code. The rules for horizontal ......
Read more >std::fmt - Rust
To convert a single value to a string, use the to_string method. This will use the Display formatting trait.
Read more >Configuring Rustfmt
Skip formatting the bodies of macro invocations with the following names. rustfmt will not format any macro invocation for macros with names set...
Read more >The Go Programming Language Specification
To allow complex statements to occupy a single line, a semicolon may be omitted before a closing ")" or "}" . To reflect...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I like this one…
but would like to extend it a bit more
foo = bar.<100 characters +> # fmt: pass
if i place at the end of the statement - it should work as well (not only before the statement)
The reason why I uninstalled black 😦