-
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
Incompatible with click 8.1.0 (ImportError: cannot import name '_unicodefun' from 'click') #2964
Incompatible with click 8.1.0 (ImportError: cannot import name '_unicodefun' from 'click') #2964
Comments
@stumpylog |
I just came here to open a very similar issue. The issue is caused by the release of click 8.1.0. Install |
+1: We have a failure in ( |
|
Works around psf/black#2964
For those that are running - repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
additional_dependencies: ['click==8.0.4'] Update - new version is available- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black |
We should probably pin to <8.1.0 for now. I can help get a release out later today to do that. |
Why was black importing an internal module? I was not expecting this to be the change that caused issues. Sorry about that. |
Looks like this is why: def patch_click() -> None:
"""Make Click not crash on Python 3.6 with LANG=C.
On certain misconfigured environments, Python 3 selects the ASCII encoding as the
default which restricts paths that it can access during the lifetime of the
application. Click refuses to work in this scenario by raising a RuntimeError.
In case of Black the likelihood that non-ASCII characters are going to be used in
file paths is minimal since it's Python source code. Moreover, this crash was
spurious on Python 3.7 thanks to PEP 538 and PEP 540.
"""
try:
from click import core
from click import _unicodefun
except ModuleNotFoundError:
return
for module in (core, _unicodefun):
if hasattr(module, "_verify_python3_env"):
module._verify_python3_env = lambda: None # type: ignore
if hasattr(module, "_verify_python_env"):
module._verify_python_env = lambda: None # type: ignore So funnily enough, this should still work, it's just catching the wrong exception. |
The import doesn't raise The code would need to be changed to |
Well good news at least, that whole patch isn't needed anymore, since Click itself is now at the same point of not raising locale encoding errors. 😄 |
This causing black to fail when run on Google Colab right now as well. |
Please use Black 22.3.0 (or newer) which was just released to fix this issue or pin Click to 8.0.0, 8.0.1, 8.0.2, 8.0.3, or 8.0.4.
~ @ichard26 at March 28 3:15 PM EST
So hey y'all, CI is broken eh?
Anyway, we are aware the most recent release of Click, 8.1.0, is breaking Black. This is because Black imports an internal module so Python 3.6 users with misconfigured LANG continues to work mostly properly. The code that patches click was supposed to be resilient to the module disappearing but the code was catching the wrong exception.
To unbreak your CI, please pin Click to 8.0.0, 8.0.1, 8.0.2, 8.0.3, or 8.0.4. We are working on a more longterm fix (probably fixing the patching code or getting rid of it entirely) and will try to get a release out soon.
~ @ichard26 at March 28 2:29 PM EST
Describe the bug
The Github Action step:
fails with the following trackeback:
To Reproduce
Run the
black
action on a Github runner, configured as above.Expected behavior
The action should only fail if files are not formatted.
Environment
OS:
runs-on: ubuntu-20.04
Version:
22.1.0
Action:
@stable
Python version:
3.8
I believeAdditional context
The text was updated successfully, but these errors were encountered: