Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:
Operating system:
Python version: 3.7 is installed but I'm in a virtualenv running 2.7
Black version:
Does also happen on master:
To answer the last question, you have two options:
pip install -e .;python setup.py test; andblack like you did last time.Hi, I work at a robotics company and I am attempting to set up a pre-commit hook for our repo.
As most of our tools use python2.7 I am attempting to set up pre-commit for python2.7
When attempting to install pre-commit for my repository I fill my .pre-commit-config.yaml as follows:
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python2.7
When I then proceed to commit .pre-commit-config.yaml I run into the following error:
[INFO] Installing environment for https://github.com/ambv/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/bin/python2.7', '/Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/bin/pip', 'install', '.')
Return code: 1
Expected return code: 0
Output:
Processing /Users/joel/.cache/pre-commit/repotfwhre6k
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
Complete output from command /Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/bin/python2.7 /Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/w8/ll36bzd537bgwgjwqtvy86hc0000gn/T/tmpwlo16H:
Traceback (most recent call last):
File "/Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Users/joel/.cache/pre-commit/repotfwhre6k/py_env-python2.7/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
return hook(config_settings)
File "/private/var/folders/w8/ll36bzd537bgwgjwqtvy86hc0000gn/T/pip-build-env-VhK8Xn/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 130, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/private/var/folders/w8/ll36bzd537bgwgjwqtvy86hc0000gn/T/pip-build-env-VhK8Xn/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 112, in _get_build_requires
self.run_setup()
File "/private/var/folders/w8/ll36bzd537bgwgjwqtvy86hc0000gn/T/pip-build-env-VhK8Xn/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 211, in run_setup
self).run_setup(setup_script=setup_script)
File "/private/var/folders/w8/ll36bzd537bgwgjwqtvy86hc0000gn/T/pip-build-env-VhK8Xn/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 126, in run_setup
exec(compile(code, __file__, 'exec'), locals())
repos:
File "setup.py", line 13
def get_long_description() -> str:
^
SyntaxError: invalid syntax
I was wondering if anyone has faced a similar issue and knows of a workaround.
Thanks!
Black will never run with python 2.7 so I guess the only reasonable thing you can do is to install it into its own virtualenv
Okay, sorry. I wasn't clear on this. My end goal is to add a pre-commit hook to lint python2.7 code
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.6
If I am in a virtualenv running python3.6 with the following config, will black successfully lint python2.7 code?
Yes :)
Most helpful comment
Yes :)