purcell/emacs-reformatter

yapf error: "yapf: input filenames did not match any python files"

lld2001 opened this issue · 5 comments

I use the following config to format python code:

(reformatter-define yapf :program "yapf" :args '("-"))

yapf does not format caused by the error:

yapf: input filenames did not match any python files

My env is "GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2022-07-01".

I debug with the following:

(apply 'call-process "yapf"
	   "d:/msys64/home/hh/test/hello.py"
       '((:file "c:/Users/hh/AppData/Local/Temp/yapfoKFr2b") "c:/Users/hh/AppData/Local/Temp/yapfPBnoV2")
       nil
       '("-"))

and add print("argv",argv) in yapf's main() function. The output of temp files are:

image

Looks like yapf does not support the - argument. Just leave off that argument: the yapf README says that if you pass it no filenames, it reads from stdin.

I tested by removing - argument, the error still same.

and the following snippet also failed.

(apply 'call-process "yapf"
	   "d:/msys64/home/hh/test/hello.py"
       '((:file "c:/Users/hh/AppData/Local/Temp/yapfoKFr2b") "c:/Users/hh/AppData/Local/Temp/yapfPBnoV2")
       nil
       '(""))

Thank you for your tip. I finally fixed the error by set :args to nil.

(reformatter-define yapf :program "yapf" :args nil)

:args is optional so you can just omit it, I believe.