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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure blib2to3.pygram is initialized before use #4224

Merged
merged 1 commit into from Mar 3, 2024

Conversation

Zac-HD
Copy link
Contributor

@Zac-HD Zac-HD commented Feb 12, 2024

For the last week or so, I've had a frustratingly irreproducible problem in Hypothesis CI, which gives me

INTERNALERROR>     pretty = black.format_str(unformatted, mode=mode)
INTERNALERROR>   File "src\black\__init__.py", line 1224, in format_str
INTERNALERROR>   File "src\black\__init__.py", line 1264, in _format_str_once
INTERNALERROR>   File "src\black\nodes.py", line 159, in visit
INTERNALERROR>   File "src\blib2to3\pytree.py", line 43, in type_repr
INTERNALERROR> ImportError: cannot import name 'python_symbols' from 'blib2to3.pygram' 

I'm now pretty sure that this is because blib2to3.pytree.type_repr() tries to import pygram.python_symbols, but this name is created by the initialize() function and that apparently hasn't been called yet. Which implies that black.nodes hasn't been imported, which is pretty surprising to me, but 馃し. Anyway, I'm working around this downstream regardless, but figured that I'd open a PR rather than a plain issue in case this was a helpful fix.

Thanks again for maintaining Black!

Copy link

diff-shades reports zero changes comparing this PR (8ab7a22) to main (a201003).


What is this? | Workflow run | diff-shades documentation

@JelleZijlstra
Copy link
Collaborator

I wonder if this is a mypyc issue, though then I'm not sure how it would be inconsistent.

This PR seems simple enough so I'm inclined to accept it.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Mar 3, 2024

Thanks @JelleZijlstra - I think if you apply the 'skip news' label this will be mergeable?

@JelleZijlstra JelleZijlstra added the skip news Pull requests that don't need a changelog entry. label Mar 3, 2024
@JelleZijlstra JelleZijlstra merged commit f03ee11 into psf:main Mar 3, 2024
46 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news Pull requests that don't need a changelog entry.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants