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

Bump Black to 24.2.2 #41

Open
angstwad opened this issue May 1, 2024 · 0 comments
Open

Bump Black to 24.2.2 #41

angstwad opened this issue May 1, 2024 · 0 comments

Comments

@angstwad
Copy link

angstwad commented May 1, 2024

Black released https://github.com/psf/black/releases/tag/24.4.2 last week addressing f-string parsing. Can you pull in these changes?

$ pyink --version
pyink, 24.3.0 (compiled: no)
Python (CPython) 3.12.2

Given a simple test file (pyink-test.py):

def main():
    d = {"foo": "bar"}
    print(f"{d['foo']}")


if __name__ == "__main__":
    main()

Results in:

$ /path/to/my/venv/bin/python -m pyink -v pyink-test.py
Identified `/path/to/my/venv` as project root containing a .git directory.
Using configuration from project root.
target_version: ['py312']
Found input source: "pyink-test.py"
Traceback (most recent call last):
  File "/path/to/my/venv/lib/python3.12/site-packages/pyink/__init__.py", line 950, in reformat_one
    if changed is not Changed.CACHED and format_file_in_place(
                                         ^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/venv/lib/python3.12/site-packages/pyink/__init__.py", line 992, in format_file_in_place
    dst_contents = format_file_contents(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/venv/lib/python3.12/site-packages/pyink/__init__.py", line 1124, in format_file_contents
    check_stability_and_equivalence(
  File "/path/to/my/venv/lib/python3.12/site-packages/pyink/__init__.py", line 1098, in check_stability_and_equivalence
    assert_equivalent(src_contents, dst_contents)
  File "/path/to/my/venv/lib/python3.12/site-packages/pyink/__init__.py", line 1592, in assert_equivalent
    raise ASTSafetyError(
pyink.parsing.ASTSafetyError: INTERNAL ERROR: Black produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_qpj__4sq.log
error: cannot format pyink-test.py: INTERNAL ERROR: Black produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_qpj__4sq.log

Oh no! 💥 💔 💥
1 file failed to reformat.

Upgrading Black in the same venv, however:

$ black --version
python -m black, 24.4.2 (compiled: yes)
Python (CPython) 3.12.2

Black 24.4.2 works:

$ /path/to/my/venv/bin/python  -m black -v pyink-test.py
Identified `/path/to/my/venv` as project root containing a .git directory.
Using configuration from project root.
target_version: ['py312', 'py313']
Found input source: "pyink-test.py"
pyink-test.py wasn't modified on disk since last run.

All done! ✨ 🍰 ✨
1 file left unchanged.
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

1 participant