blackdoc icon indicating copy to clipboard operation
blackdoc copied to clipboard

Black compatibility : relative vs absolute path

Open Nodd opened this issue 1 year ago • 0 comments

I noticed a minor incompatibility between black and blackdoc: black displays absolute filenames in the console while blackdoc displays relative paths. This would not be a problem, except that is renders blackdoc incompatible with black-gl-code-quality. I think that it can be easily fixed on this side.

Here is the error:

$ blackdoc --check . 2>&1 | black-gl-cq
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\XXX\Scripts\black-gl-cq.exe\__main__.py", line 7, in <module>
  File "D:\XXX\Lib\site-packages\black_gl_code_quality\__main__.py", line 42, in main
    output = parse_simple_mode(lines, severity)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\XXX\Lib\site-packages\black_gl_code_quality\parser.py", line 13, in parse_simple_mode
    path = Path(line.strip(magic_word).strip()).relative_to(Path.cwd())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\XXX\Lib\pathlib.py", line 730, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: 'XXX.py' is not in the subpath of 'D:\\YYY' OR one path is relative and the other is absolute.

Nodd avatar Sep 17 '24 15:09 Nodd