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

Error on some assignment expressions #1898

Closed
dmyersturnbull opened this issue Jan 2, 2021 · 2 comments
Closed

Error on some assignment expressions #1898

dmyersturnbull opened this issue Jan 2, 2021 · 2 comments
Labels
T: bug Something isn't working

Comments

@dmyersturnbull
Copy link

Black seems to break on some assignment expressions.

This works fine:

if (version := get_version()) is not None:

This breaks:

if (version := get_version() is not None):

It should either do nothing or remove parentheses as per #1656.

  • Version: master head as of 2020-01-01 (f07832e)
  • OS and Python version: Windows, Python 3.9.1 (virtualenv inside Miniconda env)
@dmyersturnbull dmyersturnbull added the T: bug Something isn't working label Jan 2, 2021
@ichard26
Copy link
Collaborator

ichard26 commented Jan 3, 2021

Thanks for the bug report! Unforutunately I can't reproduce the bug you're describing using the Black Playground and locally with CPython 3.8.5 and Ubuntu 20.04.01 LTS installed:

(black) ichard26@acer-ubuntu:~/programming/oss/black$ git log -n1
commit f07832eac44eb38f8b048aae3e1de3512a06057c (HEAD -> main, upstream/master)
Author: Paul "TBBle" Hampson <[email protected]>
Date:   Sat Jan 2 05:54:35 2021 +1100

    Use Prettier pre-commit mirror (#1896)
    
    This fixes Prettier install failures similar to those seen in
    https://github.com/prettier/prettier/issues/9459, and is the solution
    recommended there.
    
    Signed-off-by: Paul "TBBle" Hampson <[email protected]>
(black) ichard26@acer-ubuntu:~/programming/oss/black$ echo "if (version := get_version() is not None):
    pass" > test.py
(black) ichard26@acer-ubuntu:~/programming/oss/black$ black test.py --diff --check --color
All done! ✨ 🍰 ✨
1 file would be left unchanged.

I also tested in a CPython 3.9.1 virtualenv and still no error.

By any chance were you getting black produced different code on the second pass of the formatter errors? If yes, then I'm guessing you were hitting #1588 which is fixed on master although the fix hasn't been shipped in any release. If not, what error? The other two options are 1. black produced invalid code errors, OR 2. uncaught exceptions.

@dmyersturnbull
Copy link
Author

@ichard26 Yes, I am seeing that. (I should have pasted the error message!)

Assuming #1588 is the underlying issue, I'll go ahead and close this.

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

No branches or pull requests

2 participants