how to apply yapf to every python file under a directory?
up vote
0
down vote
favorite
I have installed Google yapf (yet another python formatter) under a project and try to format all my python files in-place, however I got the following error:
$ yapf -i -r files **.py
yapf: Input filenames did not match any python files
why yapf is incapable of understanding pattern? What should I do to achieve the same thing?
EDIT I also tried yapf -ir as suggested but I got:
$ yapf -ir
usage: yapf [-h] [-v] [-d | -i] [-r | -l START-END] [-e PATTERN]
[--style STYLE] [--style-help] [--no-local-style] [-p] [-vv]
[files [files ...]]
yapf: error: cannot use --in-place or --diff flags when reading from stdin
which is strange as I'm not reading from stdin
python python-3.x yapf
add a comment |
up vote
0
down vote
favorite
I have installed Google yapf (yet another python formatter) under a project and try to format all my python files in-place, however I got the following error:
$ yapf -i -r files **.py
yapf: Input filenames did not match any python files
why yapf is incapable of understanding pattern? What should I do to achieve the same thing?
EDIT I also tried yapf -ir as suggested but I got:
$ yapf -ir
usage: yapf [-h] [-v] [-d | -i] [-r | -l START-END] [-e PATTERN]
[--style STYLE] [--style-help] [--no-local-style] [-p] [-vv]
[files [files ...]]
yapf: error: cannot use --in-place or --diff flags when reading from stdin
which is strange as I'm not reading from stdin
python python-3.x yapf
That's not what I suggested...
– larsks
Nov 18 at 13:30
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have installed Google yapf (yet another python formatter) under a project and try to format all my python files in-place, however I got the following error:
$ yapf -i -r files **.py
yapf: Input filenames did not match any python files
why yapf is incapable of understanding pattern? What should I do to achieve the same thing?
EDIT I also tried yapf -ir as suggested but I got:
$ yapf -ir
usage: yapf [-h] [-v] [-d | -i] [-r | -l START-END] [-e PATTERN]
[--style STYLE] [--style-help] [--no-local-style] [-p] [-vv]
[files [files ...]]
yapf: error: cannot use --in-place or --diff flags when reading from stdin
which is strange as I'm not reading from stdin
python python-3.x yapf
I have installed Google yapf (yet another python formatter) under a project and try to format all my python files in-place, however I got the following error:
$ yapf -i -r files **.py
yapf: Input filenames did not match any python files
why yapf is incapable of understanding pattern? What should I do to achieve the same thing?
EDIT I also tried yapf -ir as suggested but I got:
$ yapf -ir
usage: yapf [-h] [-v] [-d | -i] [-r | -l START-END] [-e PATTERN]
[--style STYLE] [--style-help] [--no-local-style] [-p] [-vv]
[files [files ...]]
yapf: error: cannot use --in-place or --diff flags when reading from stdin
which is strange as I'm not reading from stdin
python python-3.x yapf
python python-3.x yapf
edited Nov 18 at 6:17
asked Nov 18 at 3:02
tribbloid
1,86952549
1,86952549
That's not what I suggested...
– larsks
Nov 18 at 13:30
add a comment |
That's not what I suggested...
– larsks
Nov 18 at 13:30
That's not what I suggested...
– larsks
Nov 18 at 13:30
That's not what I suggested...
– larsks
Nov 18 at 13:30
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The first problem is that wildcard expansion happens in the shell, before the command line even executes. When you run:
somecommand *.py
That command doesn't know you typed a *
. All it knows is that you passed in a list of files. In other words, yapf
is incapable of understanding the pattern because it never sees the pattern.
The second problem is that **
isn't a valid shell file globbing pattern. That's semantically equivalent to *
, so running yapf -ir files **.py
will only process any .py
files contained in your current directory and inside the files
directory.
If you want to run yapf
recursively on all your Python files, starting in your current directory, there are a few solutions. The simplest is probably:
yapf -ir .
This will process all .py
files in your current directory and its children. If you want more control over the selection of files, use find
and xargs
:
find . -name '*.py' -print0 | xargs -0 yapf -i
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
You forgot the.
in the command in your example. Since you didn't passyapf
a list of files, it thinks you're trying to process Python input on stdin.
– larsks
Nov 18 at 13:30
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The first problem is that wildcard expansion happens in the shell, before the command line even executes. When you run:
somecommand *.py
That command doesn't know you typed a *
. All it knows is that you passed in a list of files. In other words, yapf
is incapable of understanding the pattern because it never sees the pattern.
The second problem is that **
isn't a valid shell file globbing pattern. That's semantically equivalent to *
, so running yapf -ir files **.py
will only process any .py
files contained in your current directory and inside the files
directory.
If you want to run yapf
recursively on all your Python files, starting in your current directory, there are a few solutions. The simplest is probably:
yapf -ir .
This will process all .py
files in your current directory and its children. If you want more control over the selection of files, use find
and xargs
:
find . -name '*.py' -print0 | xargs -0 yapf -i
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
You forgot the.
in the command in your example. Since you didn't passyapf
a list of files, it thinks you're trying to process Python input on stdin.
– larsks
Nov 18 at 13:30
add a comment |
up vote
1
down vote
accepted
The first problem is that wildcard expansion happens in the shell, before the command line even executes. When you run:
somecommand *.py
That command doesn't know you typed a *
. All it knows is that you passed in a list of files. In other words, yapf
is incapable of understanding the pattern because it never sees the pattern.
The second problem is that **
isn't a valid shell file globbing pattern. That's semantically equivalent to *
, so running yapf -ir files **.py
will only process any .py
files contained in your current directory and inside the files
directory.
If you want to run yapf
recursively on all your Python files, starting in your current directory, there are a few solutions. The simplest is probably:
yapf -ir .
This will process all .py
files in your current directory and its children. If you want more control over the selection of files, use find
and xargs
:
find . -name '*.py' -print0 | xargs -0 yapf -i
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
You forgot the.
in the command in your example. Since you didn't passyapf
a list of files, it thinks you're trying to process Python input on stdin.
– larsks
Nov 18 at 13:30
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The first problem is that wildcard expansion happens in the shell, before the command line even executes. When you run:
somecommand *.py
That command doesn't know you typed a *
. All it knows is that you passed in a list of files. In other words, yapf
is incapable of understanding the pattern because it never sees the pattern.
The second problem is that **
isn't a valid shell file globbing pattern. That's semantically equivalent to *
, so running yapf -ir files **.py
will only process any .py
files contained in your current directory and inside the files
directory.
If you want to run yapf
recursively on all your Python files, starting in your current directory, there are a few solutions. The simplest is probably:
yapf -ir .
This will process all .py
files in your current directory and its children. If you want more control over the selection of files, use find
and xargs
:
find . -name '*.py' -print0 | xargs -0 yapf -i
The first problem is that wildcard expansion happens in the shell, before the command line even executes. When you run:
somecommand *.py
That command doesn't know you typed a *
. All it knows is that you passed in a list of files. In other words, yapf
is incapable of understanding the pattern because it never sees the pattern.
The second problem is that **
isn't a valid shell file globbing pattern. That's semantically equivalent to *
, so running yapf -ir files **.py
will only process any .py
files contained in your current directory and inside the files
directory.
If you want to run yapf
recursively on all your Python files, starting in your current directory, there are a few solutions. The simplest is probably:
yapf -ir .
This will process all .py
files in your current directory and its children. If you want more control over the selection of files, use find
and xargs
:
find . -name '*.py' -print0 | xargs -0 yapf -i
answered Nov 18 at 4:21
larsks
111k18181193
111k18181193
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
You forgot the.
in the command in your example. Since you didn't passyapf
a list of files, it thinks you're trying to process Python input on stdin.
– larsks
Nov 18 at 13:30
add a comment |
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
You forgot the.
in the command in your example. Since you didn't passyapf
a list of files, it thinks you're trying to process Python input on stdin.
– larsks
Nov 18 at 13:30
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
thanks a lot, the second command works properly, the first one doesn't, as I have shown in my question update.
– tribbloid
Nov 18 at 6:20
You forgot the
.
in the command in your example. Since you didn't pass yapf
a list of files, it thinks you're trying to process Python input on stdin.– larsks
Nov 18 at 13:30
You forgot the
.
in the command in your example. Since you didn't pass yapf
a list of files, it thinks you're trying to process Python input on stdin.– larsks
Nov 18 at 13:30
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357514%2fhow-to-apply-yapf-to-every-python-file-under-a-directory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
That's not what I suggested...
– larsks
Nov 18 at 13:30