question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

# fmt: pass - ignore formatting for single statements

See original GitHub issue

Feature 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

  1. Current solution
# fmt: off
ugly_code=('but I want it this way')
even_more=('dont\'t judge me')
# fmt: on
  1. #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
  2. Disable formatting for certain expressions only. #798
  3. 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:closed
  • Created 4 years ago
  • Reactions:23
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
vitalikcommented, Mar 10, 2020

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)

1reaction
prashanth-samscommented, Sep 12, 2020

The reason why I uninstalled black 😦

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found