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

Black reindents Py:Percent/Spyder IDE comments destroying them. #1542

Closed
Skylion007 opened this issue Jul 10, 2020 · 1 comment
Closed

Black reindents Py:Percent/Spyder IDE comments destroying them. #1542

Skylion007 opened this issue Jul 10, 2020 · 1 comment
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working

Comments

@Skylion007
Copy link

Skylion007 commented Jul 10, 2020

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

Full instructions for reproduce are provided here: mwouts/jupytext#562

Expected behavior A clear and concise description of what you expected to happen.
Black shouldn't reindent # %% blocks, but it will try to and that causes issues since it not longer represents break points for Spyder, VSCode, JuPyText or other IDEs. Splitting an if statement or function so that Spyder will no longer recognize it as such. Replacing the comments with the equivalent #%% leads to the same behavior.

I've even tried to guard these comments with #fmt: off and #fmt: on but that hasn't worked. My only current workaround is to use sed find and replacements directly after black which unfortunately breaks a lot of the functionality.

The tests located here do not cover this edge case unfortunately and should be updated.

Environment (please complete the following information):

  • Version: [e.g. master] black, version 19.10b0
  • OS and Python version: [e.g. Linux/Python 3.7.4rc1] Linux/Python 3.6.7

Does this bug also happen on master? To answer this, you have two options:
Yes

  1. Use the online formatter at https://black.now.sh/?version=master, which will use the
    latest master branch.
  2. Or run Black on your machine:
    • create a new virtualenv (make sure it's the same Python version);
    • clone this repository;
    • run pip install -e .;
    • make sure it's sane by running python -m unittest; and
    • run black like you did last time.

Additional context These features are important for JuPyText jupyter notebook scripts and currently make maintaining them more difficult.

@Skylion007 Skylion007 added the T: bug Something isn't working label Jul 10, 2020
@ichard26 ichard26 added the F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. label Aug 7, 2020
@JelleZijlstra
Copy link
Collaborator

Let's discuss this in #3668.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants