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

skip string normalization no longer ignores triple quote strings, like docstrings #1634

Closed
zdelagrange opened this issue Aug 26, 2020 · 4 comments · Fixed by #1637
Closed
Labels
T: bug Something isn't working

Comments

@zdelagrange
Copy link

Describe the bug

previously running with --skip-string-normalization would ignore triple-quoted strings that used single quote character '

To Reproduce Steps to reproduce the behavior:

  1. Take this file '...'
def test_function():
    '''this is my docstring'''
    pass
  1. Run Black on it with these arguments '....'
    --skip-string-normalization
  2. See error
    it modifies the triple-quoted strings to double-quote character

do the same steps after installing 19.10.0b

Expected behavior

skip string normalization should ignore triple quoted strings

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: linux python3.6

Does this bug also happen on master?
yes

Additional context
n/a

@zdelagrange zdelagrange added the T: bug Something isn't working label Aug 26, 2020
@ichard26
Copy link
Collaborator

ichard26 commented Aug 26, 2020

Hello @zdelagrange,

I cannot reproduce the bug:

(black-rHKUX7ap) R:\Programming\black>type temp.py
def test_function():
    '''this is my docstring'''
    pass

(black-rHKUX7ap) R:\Programming\black>black temp.py --diff --color -S
All done! ✨ 🍰 ✨
1 file would be left unchanged.

Environment:

  • Black version: master (20f74c2)
  • Python version: CPython 3.8.1
  • OS version: Windows 10 Home Edition Build 18363

@zdelagrange
Copy link
Author

alrighty, here's a play-by-play of my console

black_test ❯ pip freeze | grep black
black==19.10b0

~/src/black_test master*
black_test ❯ cat black.py
def function_one(arg1, arg2, arg3):
    '''
    docstring
    '''
    pass

~/src/black_test master*
black_test ❯ black --skip-string-normalization black.py
All done! ✨ 🍰 ✨
1 file left unchanged.

~/src/black_test master*
black_test ❯ pip install black --upgrade
Collecting black
  Using cached https://files.pythonhosted.org/packages/8a/7c/a6cdd4c69e1377d917e0b9fe44acb8f42d340ac35bcf66020136cd00c62a/black-20.8b1-py3-none-any.whl
Requirement already satisfied, skipping upgrade: typed-ast>=1.4.0 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (1.4.1)
Requirement already satisfied, skipping upgrade: pathspec<1,>=0.6 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (0.8.0)
Requirement already satisfied, skipping upgrade: appdirs in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (1.4.4)
Requirement already satisfied, skipping upgrade: click>=7.1.2 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (7.1.2)
Requirement already satisfied, skipping upgrade: toml>=0.10.1 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (0.10.1)
Requirement already satisfied, skipping upgrade: regex>=2020.1.8 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (2020.7.14)
Requirement already satisfied, skipping upgrade: mypy-extensions>=0.4.3 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (0.4.3)
Requirement already satisfied, skipping upgrade: dataclasses>=0.6; python_version < "3.7" in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (0.7)
Requirement already satisfied, skipping upgrade: typing-extensions>=3.7.4 in /Users/zacdelagrange/envs/black_test/lib/python3.6/site-packages (from black) (3.7.4.3)
Installing collected packages: black
  Found existing installation: black 19.10b0
    Uninstalling black-19.10b0:
      Successfully uninstalled black-19.10b0
Successfully installed black-20.8b1
You are using pip version 18.1, however version 20.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

~/src/black_test master*
black_test ❯ cat black.py
def function_one(arg1, arg2, arg3):
    '''
    docstring
    '''
    pass

~/src/black_test master*
black_test ❯ black --skip-string-normalization black.py
reformatted black.py
All done! ✨ 🍰 ✨
1 file reformatted.

~/src/black_test master*
black_test ❯ cat black.py
def function_one(arg1, arg2, arg3):
    """
    docstring
    """
    pass

~/src/black_test master*
black_test ❯

@ichard26
Copy link
Collaborator

Oh my that is a surprising bug! I can reproduce using the same environment as I posted above.

Git bisect points to commit a4c11a7, from "Re-indent the contents of docstrings" (PR #1053).

@ambv
Copy link
Collaborator

ambv commented Aug 26, 2020

Good catch, we'll fix it in the next release which is planned for the week of Sept 28th (likely Oct 1). If this is a deal breaker for you, I suggest pinning to 19.10b0 in the mean time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants