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

Support Python 3.10 features, especially match, request #59

Closed
deeppunster opened this issue Jan 8, 2022 · 9 comments
Closed

Support Python 3.10 features, especially match, request #59

deeppunster opened this issue Jan 8, 2022 · 9 comments

Comments

@deeppunster
Copy link

Currently blue (version 0.7.0) supports most features of Python 3.10 via black (version 21.7.b0), but not the match statement. Black version 21.12b0 apparently does (see black issue #2662. However, running blue with that version of black produces this error:

  $ blue src
  Traceback (most recent call last):
    File ".../venv/bin/blue", line 8, in <module>
      sys.exit(main())
    File ".../venv/lib/python3.10/site-packages/blue/__init__.py", line 385, in main
      assert config_param.name == 'config'
  AssertionError

Apparently, blue does not allow the option --target-version py310 nor the equivalent to be set in the pyproject.toml file (tools.black ...).
Version info for current version of blue:

$ poetry show blue
name         : blue
version      : 0.7.0
description  : Blue -- Some folks like black but I prefer blue.

dependencies
 - black 21.7b0
 - flake8 3.8.4

Given that blue only patches black and that black does not consider version 21.12b0 to fully support match statements, is it premature to ask that blue can allow the interim version of black to be used with it?

@grantjenks
Copy link
Owner

It’s our goal to stay current with Black as new Python features are supported. Thanks for pointing out the issue. Could you share a snippet of code that black currently formats but blue does not?

@deeppunster
Copy link
Author

Certainly. Here is a match statement that black will handle if "--target-version py310" is specified:

order = 1

match order:
    case 1:
        print("Matched number one")
    case 2:
        print("Matched number two")
    case _:
        print("No match")

And the output is:

Matched number one

@deeppunster
Copy link
Author

deeppunster commented Jan 13, 2022 via email

@deeppunster
Copy link
Author

Oh, this works with black 21.12b0 or later.

@chrisguillory
Copy link

Is there any update on this? Perhaps there's a workaround available? We are on Python 3.10 and would like to use the new match statement /w blue. Thanks!

@grantjenks
Copy link
Owner

I believe #67 brought in support for Python 3.10 and the match statement. If you want, you can try formatting with HEAD and seeing how the diffs look.

Fyi @warsaw who was also going to check diffs.

@chrisguillory
Copy link

chrisguillory commented Apr 25, 2022

Thanks! We are using #67 successfully and our diffs look good. Any idea when this new version might be released? (for now we install blue from commit hash).

@warsaw
Copy link
Collaborator

warsaw commented Apr 25, 2022

Thanks for the confirmation @chrisguillory - I'll do some quick checks myself and tag a new release. Automation should take it from there.

@warsaw
Copy link
Collaborator

warsaw commented Apr 25, 2022

LGTM

@warsaw warsaw closed this as completed Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants