-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve the the blib2to3 grammar caching mechanism #1143
Comments
Looks like I found the cause, thanks for the fix @AlJohri! |
Has there been a PR on this yet? |
I'm reopening this issue since 1. the issue still exists and 2. the fix #1223 proposes isn't ideal. I see two possible solutions to this issue:
While option 1 is simpler, the cache directory would be created when simply importing Black. Applications that use Black as a library might never use the cache, yet the cache dir would still be created, not an ideal side-effect. Option 2 is a bit more involved but it avoids the unnecessary side-effect mentioned above. Anyway the other caches like the cache which records which files are well-formatted already behave this way. It's only the grammar table cache that tries to write to disk when Black is imported.
|
I am still seeing this error with Is there any update or workaround for this error? |
Had this happen on macos; as with the OP, immediate fix was to
This issue showed up at about the same time as I updated various libs in my environment, and there's a |
just manually mkdir -p to solve this error. |
Hi, I got this error too with papermill |
I get this error trying to run
Before I go and remove black/papermill from my workflow, is there a way to move the CACHE_DIR to a predictable location? Can I set this with an environmental variable? Can the cache go into |
@AlJohri This workaround does not work: $ python -c "import logging; logging.basicConfig(level='INFO'); import black"
INFO:blib2to3.pgen2.driver:Generating grammar tables from /luna4/maye/miniconda3/envs/py38/lib/python3.8/site-packages/blib2to3/Grammar.txt
INFO:blib2to3.pgen2.driver:Writing grammar tables to /u/paige/maye/.cache/black/21.11b1/Grammar3.8.12.final.0.pickle
INFO:blib2to3.pgen2.driver:Writing failed: [Errno 2] No such file or directory: '/u/paige/maye/.cache/black/21.11b1/tmpp8nlg3be'
INFO:blib2to3.pgen2.driver:Generating grammar tables from /luna4/maye/miniconda3/envs/py38/lib/python3.8/site-packages/blib2to3/PatternGrammar.txt
INFO:blib2to3.pgen2.driver:Writing grammar tables to /u/paige/maye/.cache/black/21.11b1/PatternGrammar3.8.12.final.0.pickle
INFO:blib2to3.pgen2.driver:Writing failed: [Errno 2] No such file or directory: '/u/paige/maye/.cache/black/21.11b1/tmp0dmgsyif' |
This issue is still a problem. Perhaps someone could document how to use black as a library so that this warning is not issued? |
Please follow #779 for a discussion about Black's public Python API, which doesn't exist yet. This definitely relates to that, but "importing Black" isn't exactly a thing yet 😄 at least officially. |
I think #3193 removed the logging? There's also e.g. |
I get an error upon launching Jupyter Lab with the jupyterlab_code_formatter extension enabled:
After manually creating the folder
C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0
and relaunching Jupyter lab the error disappears (even though the folder seems to stay empty).The error appears to originate from this line. It might be related to #192. I think this line fails because the cache directory does not exist, but I don't understand why it doesn't exist.
Other users confirmed this happens on linux and with version 19.10b as well in this issue.
I tried to find the cause of this issue in the extension, but it doesn't seem to do anything out of the ordinary with the cache folder, so I was hoping someone here can tell me why the cache folder would not exist?
The text was updated successfully, but these errors were encountered: