Closed amaank404 closed 3 years ago
pre-commit
is a plugin that runs automatically on git
events. If you want you can open a PR to include the steps like so:
To forget about coding style and let pre-commit fix your flake8
/isort
/black
issue.
$ python -m pip install pre-commit
$ pre-commit install
That's it!
that seems to look good, almost 70% percent of pull request I see fails pre-commit which was hard to fix manually until i came to know we can use this locally to make changes
hey , @dhruvmanila i would Love to work on this issue . Pls assign this issue to me .
Well @Joe-Sin7h, You can start working and link this issue in your PR. No need to get assigned
1flake8/ isort/ black.
Instalar el compromiso previo: $ python -m pip install pre-commit Y entonces: $ pre-commit installpip install pre-commit correr pre-commit run --all-files
wget https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc-6.1/gcc/libgcc-6.3.0-2.aix6.1.ppc.rpm wget https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc-6.1/gcc/libstdcplusplus-6.3.0-2.aix6.1.ppc.rpmflake8/ isort/ black.
Instalar el compromiso previo: $ python -m pip install pre-commit Y entonces: $ pre-commit installPR
pre-commit --versiflake8/ isort/ black.
Instalar el compromiso previo: $ python -m pip install pre-commit Y entonces: $ pre-commit installpyzarchivo de las versiones de github correr python pre-commit-#.#.#.pyz ...en lugar depre-commit ...pre-commit --versi
Sorry, We understand english
Hello, I have made the necessary changes in CONTRIBUTING.md, and I am getting the following error when I try to commit the changes:
Check that executables have shebangs.....................................Passed Check Yaml...........................................(no files to check)Skipped Fix End of Files.....................................(no files to check)Skipped Trim Trailing Whitespace.................................................Passed Fix requirements.txt.................................(no files to check)Skipped black................................................(no files to check)Skipped isort................................................(no files to check)Skipped flake8...............................................(no files to check)Skipped codespell................................................................Passed Validate filenames.......................................................An unexpected error has occurred: OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE' Check the log at C:\Users\Ashish Papanai\.cache\pre-commit\pre-commit.log
Could you please help me out?
Sure, You should try the steps yourself (Warning: they are steps for you only, complete steps have been mentioned above):
pip install pre-commit
pre-commit run -a
Also, retry the whole procedure of commiting, and then upload the C:\Users\Ashish Papanai\.cache\pre-commit\pre-commit.log
to this place
Hello @xcodz-dot The last pre-commit test i.e. Validate filenames is failing with the following error:
Validate filenames.......................................................An unexpected error has occurred: OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE'
The pre-commit.log is mentioned below: `### version information
pre-commit version: 2.9.0
sys.version:
3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
sys.executable: c:\users\ashish papanai\anaconda3\python.exe
os.name: nt
sys.platform: win32
An unexpected error has occurred: OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE'
Traceback (most recent call last):
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
yield
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\main.py", line 375, in main
return run(args.config, store, args)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 400, in run
return _run_hooks(config, hooks, args, environ)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 282, in _run_hooks
current_retval, prior_diff = _run_single_hook(
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 190, in _run_single_hook
retcode, out = language.run_hook(hook, filenames, use_color)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\languages\script.py", line 19, in run_hook
return helpers.run_xargs(hook, cmd, file_args, color=color)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\languages\helpers.py", line 136, in run_xargs
return xargs(cmd, file_args, **kwargs)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\xargs.py", line 163, in xargs
for proc_retcode, proc_out, _ in results:
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\xargs.py", line 155, in run_cmd_partition
return cmd_fn(
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\util.py", line 141, in cmd_output_b
cmd = parse_shebang.normalize_cmd(cmd)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\parse_shebang.py", line 79, in normalize_cmd
cmd = parse_filename(exe) + (exe,) + cmd[1:]
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\parse_shebang.py", line 22, in parse_filename
return parse_shebang_from_file(filename)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\identify\identify.py", line 195, in parse_shebang_from_file
with open(path, 'rb') as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE'
`
It seems something is trying to open the python executable
I recommend for you to try the official python setup instead of windows app. https://www.python.org
Tried everything, The final step is still failing. @xcodz-dot
Try running this command in root of repo instead of old one, also post your command line and log again after this:
pre-commit clean
pre-commit gc
pre-commit run -a -v --show-diff-on-failure
It is the root of the repository. i.e. E:/Git Contributions/Python
Ok try the commands
@xcodz-dot The following lines are from cmd after running the commands mentioned by you:
E:\Git Contributions\Python>pre-commit clean
Cleaned C:\Users\Ashish Papanai\.cache\pre-commit.
E:\Git Contributions\Python>pre-commit gc
0 repo(s) removed.
E:\Git Contributions\Python>pre-commit run -a -v --show-diff-on-failure
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/PyCQA/isort.
[INFO] Initializing environment for https://gitlab.com/pycqa/flake8.
[INFO] Initializing environment for https://github.com/codespell-project/codespell.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://gitlab.com/pycqa/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/codespell-project/codespell.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check that executables have shebangs.....................................Passed
- hook id: check-executables-have-shebangs
- duration: 0.39s
Check Yaml...............................................................Passed
- hook id: check-yaml
- duration: 0.34s
Fix End of Files.........................................................Passed
- hook id: end-of-file-fixer
- duration: 0.32s
Trim Trailing Whitespace.................................................Passed
- hook id: trailing-whitespace
- duration: 0.5s
Fix requirements.txt.....................................................Passed
- hook id: requirements-txt-fixer
- duration: 0.15s
black....................................................................Passed
- hook id: black
- duration: 0.88s
All done! \u2728 \U0001f370 \u2728
855 files left unchanged.
isort....................................................................Passed
- hook id: isort
- duration: 2.03s
flake8...................................................................Passed
- hook id: flake8
- duration: 11.15s
codespell................................................................Passed
- hook id: codespell
- duration: 0.68s
Validate filenames.......................................................An unexpected error has occurred: OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE'
Check the log at C:\Users\Ashish Papanai\.cache\pre-commit\pre-commit.log
E:\Git Contributions\Python>
Now please post me the log
The log is mentioned below:
pre-commit version: 2.9.0
sys.version:
3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
sys.executable: c:\users\ashish papanai\anaconda3\python.exe
os.name: nt
sys.platform: win32
An unexpected error has occurred: OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE'
Traceback (most recent call last):
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
yield
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\main.py", line 375, in main
return run(args.config, store, args)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 400, in run
return _run_hooks(config, hooks, args, environ)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 282, in _run_hooks
current_retval, prior_diff = _run_single_hook(
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 190, in _run_single_hook
retcode, out = language.run_hook(hook, filenames, use_color)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\languages\script.py", line 19, in run_hook
return helpers.run_xargs(hook, cmd, file_args, color=color)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\languages\helpers.py", line 136, in run_xargs
return xargs(cmd, file_args, **kwargs)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\xargs.py", line 163, in xargs
for proc_retcode, proc_out, _ in results:
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\xargs.py", line 155, in run_cmd_partition
return cmd_fn(
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\util.py", line 141, in cmd_output_b
cmd = parse_shebang.normalize_cmd(cmd)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\parse_shebang.py", line 79, in normalize_cmd
cmd = parse_filename(exe) + (exe,) + cmd[1:]
File "c:\users\ashish papanai\anaconda3\lib\site-packages\pre_commit\parse_shebang.py", line 22, in parse_filename
return parse_shebang_from_file(filename)
File "c:\users\ashish papanai\anaconda3\lib\site-packages\identify\identify.py", line 195, in parse_shebang_from_file
with open(path, 'rb') as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\Ashish Papanai\\AppData\\Local\\Microsoft\\WindowsApps\\python3.EXE'
try:
pip uninstall pre-commmit
pip install pre-commit
pre-commit uninstall
pre-commit install
pre-commit clean
pre-commit run -a -v
I can't help much cause the issue is with internal working
@xcodz-dot I tried to commit using WSL, any idea that why is it looking for shebang and how to fix that?
ashishpapanai@ashishpapanai:/mnt/e/Git Contributions/Python$ chmod -x CONTRIBUTING.md
ashishpapanai@ashishpapanai:/mnt/e/Git Contributions/Python$ git commit -m "Fixes Issue#3887 Guiding people using contibuting.md"
Check that executables have shebangs.....................................Failed
- hook id: check-executables-have-shebangs
- exit code: 1
CONTRIBUTING.md: marked executable but has no (or invalid) shebang!
If it isn't supposed to be executable, try: `chmod -x CONTRIBUTING.md`
If it is supposed to be executable, double-check its shebang.
Check Yaml...........................................(no files to check)Skipped
Fix End of Files.....................................(no files to check)Skipped
Trim Trailing Whitespace.................................................Passed
Fix requirements.txt.................................(no files to check)Skipped
black................................................(no files to check)Skipped
isort................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
codespell................................................................Passed
Validate filenames.......................................................Passed
I tried to remove the executable permissions of contributing.md by chmod -x CONTRIBUTING.md
But it didn't help.
how about trying pre-commit run -a
here
Also, which editor are you using?
You can try raising this issue in pre-commit repo, they might help you out
I have a simple instruction which is good to be kept in CONTRIBUTION.md. Please add this wherever it looks good:
pip install pre-commit
pre-commit run --all-files