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

Pdb breakpoint line unnecessarily get formatted #435

Closed
pavdmyt opened this issue Aug 5, 2018 · 6 comments
Closed

Pdb breakpoint line unnecessarily get formatted #435

pavdmyt opened this issue Aug 5, 2018 · 6 comments

Comments

@pavdmyt
Copy link

pavdmyt commented Aug 5, 2018

The breakpoint set using pdb: import pdb; pdb.set_trace() get formatted into 3 lines:

import pdb

pdb.set_trace()

I'm using Atom editor with plugin to apply black when saving the file. 3 lines instead of single breakpoint line is not very convenient. Maybe it is possible to add an exclusion for such kind of lines?

Environment:
Operating system: macOS High Sierra; Version 10.13.6 (17G65)
Python version: 3.6.5
Black version: 18.6b4
Does also happen on master: yes

@rooterkyberian
Copy link

work around for python 3.7: use breakpoint() built-in https://docs.python.org/3/library/functions.html#breakpoint

@zsol
Copy link
Collaborator

zsol commented Aug 5, 2018

It's unlikely we're going to make an exception for import pdb; pdb.set_trace() because that would introduce a considerable amount of complexity and it's really easy to just wrap this in # fmt: off # fmt: on if you really care about these two being on the same line IMO.

@zsol zsol closed this as completed Aug 5, 2018
@tino
Copy link

tino commented Nov 17, 2018

I agree with @pavdmyt that this would be nice to accomplish. Now I'm debugging some code, I add the pdb one liner and save, find the bug, and with the editors remove line functionality am clean again. With black that breaks up the workflow. I tried changing my pdb snippet into import pdb; pdb.set_trace() # fmt: off but that doesn't work.

Could we make single line escaping work then? That would allow this (quite common for me and my colleagues at least) workflow.

@jackbackes
Copy link

@tino -- What you want is the following:

# fmt: off
import pdb; pdb.set_trace()
# fmt: on

I've turned this into a snippet in VSCode so that all I have to do is type "pdb" as a prefix. You could do the same in your IDE for ease of use.

@avalanchy
Copy link

black will not touch this workaround

__import__("pdb").set_trace()

@ichard26
Copy link
Collaborator

Since GH-1800 on the master branch, # fmt: skip at the end of your import pdb; pdb.set_trace() line should work.

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

7 participants