Executing YAPF in Windows 10 Powershell throws Permission Denied when using .STYLE.YAPF file
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
In YAPF, there is a directory that it looks up, to find a .STYLE.YAPF file:
`~/.config/yapf/style/`
On Windows 10, this directory is located at: `C:\Users\tomma\.config\yapf\style\`
I have placed my .STYLE.YAPF file in this directory.
When executing YAPF in Powershell, it would throw a "Permissions Denied" error because of an incorrectly parsed forward slash/backwards slash in the PATH it is attempting to look in for the .STYLE.YAPF file. You can easily tell by checking the last line of the stack trace (below) for this path: `C:\\Users\\tomma/.config\\yapf\\style`
The error should have thrown something like "FileNotFoundError" instead of a "PermissionsError", but I digress, since the .STYLE.YAPF file is placed there. I did double-check to make sure that the file permissions and folder permissions are set to FULL CONTROL under my account, `tomma`. Thus, I don't believe it's a permissions issue.
Stack trace:
```
PS D:\Documents\PythonProjects\testPython> yapf .\example.py
Traceback (most recent call last):
File "d:\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\Python38\Scripts\yapf.exe\__main__.py", line 9, in
File "d:\python38\lib\site-packages\yapf\__init__.py", line 344, in run_main
sys.exit(main(sys.argv))
File "d:\python38\lib\site-packages\yapf\__init__.py", line 216, in main
changed = FormatFiles(
File "d:\python38\lib\site-packages\yapf\__init__.py", line 277, in FormatFiles
changed |= _FormatFile(filename, lines, style_config, no_local_style,
File "d:\python38\lib\site-packages\yapf\__init__.py", line 298, in _FormatFile
reformatted_code, encoding, has_change = yapf_api.FormatFile(
File "d:\python38\lib\site-packages\yapf\yapflib\yapf_api.py", line 85, in FormatFile
reformatted_source, changed = FormatCode(
File "d:\python38\lib\site-packages\yapf\yapflib\yapf_api.py", line 124, in FormatCode
style.SetGlobalStyle(style.CreateStyleFromConfig(style_config))
File "d:\python38\lib\site-packages\yapf\yapflib\style.py", line 637, in CreateStyleFromConfig
config = _CreateConfigParserFromConfigFile(style_config)
File "d:\python38\lib\site-packages\yapf\yapflib\style.py", line 672, in _CreateConfigParserFromConfigFile
with open(config_filename) as style_file:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\tomma/.config\\yapf\\style'
```
Maybe it has to do with the YAPF file, given below?
```
[style]
BASED_ON_STYLE = google
USE_TABS = true
INDENT_DICTIONARY_VALUE = true
DEDENT_CLOSING_BRACKETS = true
COALESCE_BRACKETS = false
EACH_DICT_ENTRY_ON_SEPARATE_LINE = false
ALLOW_SPLIT_BEFORE_DICT_VALUE = true
COLUMN_LIMIT = 999
ARITHMETIC_PRECEDENCE_INDICATION = true
CONTINUATION_ALIGN_STYLE = VALIGN-RIGHT
CONTINUATION_INDENT_WIDTH = 1
INDENT_WIDTH = 1
```
------------------
System information:
```
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19042 N/A Build 19042
System Type: x64-based PC
Python: Python 3.9.4
YAPF: 0.29.0 Stable
```
Contributor guide
Assessment
This issue has not been assessed yet.