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

Python 3.8 — PEP 572 compatibility #711

Closed
smartsammler opened this issue Feb 15, 2019 · 5 comments · Fixed by #935
Closed

Python 3.8 — PEP 572 compatibility #711

smartsammler opened this issue Feb 15, 2019 · 5 comments · Fixed by #935
Labels
T: enhancement New feature or request

Comments

@smartsammler
Copy link

Operating system: Fedora 29 Linux
Python version: 3.8.0a1 (build from Python.org sources)
Black version: 18.9b0
Does also happen on master: yes, localy. on black.now.sh it fails with type object 'FileMode' has no attribute 'from_configuration'

My example for a too long line in a file trying the upcoming PEP 572 Assignment Expressions failed with

error: cannot format test.py: Cannot parse: 4:23:     while not (0 < (answer := int(input("Please guess a positive number up to 10: "))) <= 10):
All done! 💥 💔 💥
1 file failed to reformat.

The example is the following:

#!/usr/bin/env python38
# -*- coding: utf-8 -*-

while not (0 < (answer := int(input("Please guess a positive number up to 10: "))) <= 10):
    print("That is not correct input, please retry.")

print(f"Your guess {answer} is not the number I chose :-p")

I don't think that this is an urgent issue, because Python 3.8 got its first alpha not long ago. I just wanted to test if it works and because it does not, and I haven't found an issue yet, I'm filing this one.

Thank you for your work!

@zsol zsol added the T: enhancement New feature or request label Feb 15, 2019
@zsol
Copy link
Collaborator

zsol commented Feb 15, 2019

Thanks for reporting. We'll definitely add support for := before 3.8 is released ;)

@gvanrossum
Copy link

Ping? 3.8 beta 1 is out now and people are testing 3.8 in their staging setup.

@rhettinger
Copy link

This is still not supported as 21 July 2019 in beta 2:

$ python3.8 --version
Python 3.8.0b2
$ python3.8 -m black --skip-string-normalization Lib/statistics.py
error: cannot format Lib/statistics.py: Cannot parse: 618:20: def quantiles(dist, /, *, n=4, method='exclusive'):
All done! 💥 💔 💥
1 file failed to reformat.

@zsol
Copy link
Collaborator

zsol commented Jul 25, 2019

@rhettinger I've opened #943 for that. I thought I'd implement it fast last night but then I looked at the cpython grammar that implements this and realized this will take a while :)

@asottile
Copy link
Contributor

This seems not fixed properly:

$ pre-commit try-repo https://github.com/psf/black --all-files --show-diff-on-failure
[INFO] Initializing environment for https://github.com/psf/black.
===============================================================================
Using config:
===============================================================================
repos:
-   repo: https://github.com/psf/black
    rev: c9689b80fbb108316b0330fc1ed444ccab419b02
    hooks:
    -   id: black
===============================================================================
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
black....................................................................Failed
hookid: black

Files were modified by this hook. Additional output:

reformatted t.py
All done! ✨ 🍰 ✨
1 file reformatted.

pre-commit hook(s) made changes.
If you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`.
To run `pre-commit` as part of git workflow, use `pre-commit install`.
All changes made by hooks:
diff --git a/t.py b/t.py
index 7aa9164..767c39b 100644
--- a/t.py
+++ b/t.py
@@ -1,2 +1,2 @@
-if (x := 1):
+if (x := 1) :
     print(x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants