Skip to content

[python 3.9] black doesn't support PEP 614 #1711

@QuentinSoubeyran

Description

@QuentinSoubeyran

Describe the bug
PEP 614 relaxed the syntax for decorators in python 3.9. However, black doesn't (yet ?) have a py39 target, and doesn't support this syntax.

To Reproduce

  1. Take this very simple file test.py
from dataclasses import dataclass
d = [dataclass]

@d[0]
class A:
    attr: int

print(A)
  1. Run Black on it : black test.py
  2. See error error: cannot format test.py: Cannot parse: 5:2: @d[0]

Expected behavior Black should accept and format code that is valid for python 3.9 (python test.py prints <class '__main__.A'> as expected).

Environment (please complete the following information):

  • Version: master (commit 811decd)
  • OS and Python version: Linux, Python 3.9.0rc1

Does this bug also happen on master?

  1. Use the online formatter at https://black.now.sh/?version=master
    This produce the above error
  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 (this fails, see Test failures with Python 3.9.0b1 #1441 )
    • run black like you did last time.

This also produce the above error

Additional context Python 3.9 is in pre-release stage, so I'm not sure if this is a bug report or a feature request - I can change to the latter. PEP 614 highlights the use-case of the syntax (with examples from PyQt5), the above file is a minimalist file to illustrate the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions