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

Formatter fails to run #16

Closed
CoatedMoose opened this issue Mar 29, 2022 · 6 comments
Closed

Formatter fails to run #16

CoatedMoose opened this issue Mar 29, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@CoatedMoose
Copy link
Contributor

Describe the bug

A freshly installed axblack (pip install axblack==20220321) fails to run with an error patching _unicodefun from click. It seems between release 8.0.4 and 8.1.0 of click, that method was removed.

To Reproduce

  1. Install 20220321 of axblack fresh (with no additional version spec for click)
  2. Run black on any project

Expected behavior

Code to be formatted.

Environment (please complete the following information):

  • Version: 20220321
  • OS and Python version: Ubuntu 20.04.4 LTS, Python 3.8

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

Did not test this on master.

Additional context

Changing my formatter install command to the following resolves the issue:

pip install axblack==20200130 "click<8.1"
@CoatedMoose CoatedMoose added the bug Something isn't working label Mar 29, 2022
@axgkl
Copy link
Member

axgkl commented Mar 30, 2022

Hi & thanks!

Removed that _unicodefun as well from patch_click => pip install axblack should work with newest click now.

=> can u verify and close, if so?

@CoatedMoose
Copy link
Contributor Author

It seems that the newest version does run.

$ pip install --upgrade --upgrade-strategy eager axblack
# snip normal looking dependency resolution
Successfully installed axblack-20220330 click-8.1.2 regex-2022.3.15
$ black ./ --exclude migrations/
# snip large number of unexpected changes of """ -> '''

The new version changes all the double-quote block strings (""") strings to single-quote ('''), which the version I was previously using (20200130) was not doing. Is this expected with the newer version? Is it configurable?

@axgkl
Copy link
Member

axgkl commented Apr 6, 2022

Can you detail what you mean here (example), triple quoted strings are still formatted to """:

/tmpblack --version                                                                 
black, version 20220330
/tmpcat r.py                                                                        
'''
mod doc

'''
def foo():
    '''func doc'''
    foo    = "bar"; baz= [ "bar"]
/tmpcat r.py| black -                                                               
"""
mod doc

"""


def foo():
    """func doc"""
    foo = 'bar'
    baz = ['bar']
reformatted -
All done! ✨ 🍰 ✨
1 file reformatted.

@CoatedMoose
Copy link
Contributor Author

Previous behaviour we used:

$ cat simple_test.py


def a_method():
    long_string = """
        This is a long
        string for testing
    """
    print(long_string)
$ black --version
black, version 20200130
$ cat simple_test.py| black -
No Python files are present to be formatted. Nothing to do 😴

With a newer version of axblack

$ black --version
black, version 20220330
$ cat simple_test.py| black -
def a_method():
    long_string = '''
        This is a long
        string for testing
    '''
    print(long_string)
reformatted -
All done! ✨ 🍰 ✨
1 file reformatted.

The long_string variable has had it's quote type changed, where that was not the behaviour in previous versions.

@axgkl
Copy link
Member

axgkl commented Apr 11, 2022

Ok, I see what you mean: The version of 2020 january 30 could not format on stdin (black -) but when you apply on the file you get in deed this:

~/repos/lc-python feat_devapp_open ⇡2 ?4 ❯ black --version                                                                            lc-python_py3.8
black, version 20200130
~/repos/lc-python feat_devapp_open ⇡2 ?4 ❯ cat a.py                                                                                   lc-python_py3.8
astring = "foo"

def a_method():
    long_string = """
        This is a long
        string for testing
    """
    print(long_string)
~/repos/lc-python feat_devapp_open ⇡2 ?4 ❯ black a.py                                                                                 lc-python_py3.8
reformatted a.py
All done! ✨ 🍰 ✨
1 file reformatted.
~/repos/lc-python feat_devapp_open ⇡2 ?4 ❯ cat a.py                                                                                   lc-python_py3.8
astring = 'foo'


def a_method():
    long_string = """
        This is a long
        string for testing
    """
    print(long_string)

Means: ALL triple quoted strings, docstrings or not, where turned to double apos.

While our documented style, since quite a while is:

2022-04-11__013

Double quotes ONLY for docstrings. Code only single quotes, triple quoted or not. I think the change followed a change the PSF/black version did also back then, once.

I cannot change it back to the old behaviour now (do find the current form also better but that is a matter of personal taste).

I would say, if you really want to keep double apo tripple quotes within your codebases, then nail the black version to 20200130 - which means, you have to nail the click version as well. Sorry for that.

@axgkl
Copy link
Member

axgkl commented Apr 13, 2022

closing - reopen or send a PR for the cli flag.
thanks again for the bug report!

@axgkl axgkl closed this as completed Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants