Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Patch new flake8 command grep #15749

Closed
wants to merge 2 commits into from

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented Mar 20, 2017

The grep was initially matching to "pandas," which is incorrect because that was also matching files containing "pandas" in the name but that were not in the main pandas directory (e.g. performance test code). This change enforces that we match to any Python files in the main pandas directory.

Also picked up compatibility issue with OSX, in which the -r flag does not exist. However, xargs terminates if the argument list is empty, which was the whole point of passing in -r in the first place.

Follow-up to #15712

The grep was initially matching to "pandas,"
which is incorrect because that was also
matching files containing "pandas" in the
name but that were not in the main pandas
directory (e.g. performance test code)

Follow-up to pandas-devgh-15712

[ci skip]
@@ -527,7 +527,7 @@ unused function. However, style-checking the diff will not catch this because
the actual import is not part of the diff. Thus, for completeness, you should
run this command, though it will take longer::

git diff master --name-only -- '*.py' | grep 'pandas' | xargs -r flake8
git diff master --name-only -- '*.py' | grep 'pandas/' | xargs -r flake8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if its worth noting but need to remove the -r on osx :<

otherwise this command looks good to me (I use it!)

Copy link
Member Author

@gfyoung gfyoung Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! But how do you tell xargs to abort the command if the list is empty on OSX? That's the whole reason why I have the -r flag there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just works

(pandas) bash-3.2$ git diff master --name-only -- '*.py' | grep 'pandas/' | xargs -r flake8
xargs: illegal option -- r
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
(pandas) bash-3.2$ git diff master --name-only -- '*.py' | grep 'pandas/' | xargs flake8

Copy link
Member Author

@gfyoung gfyoung Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. I did not realize it just aborts like that. Okay, then I'll mention that in the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback : Made doc patch regarding OSX compatibility with xargs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does -r do anyhow?

Copy link
Member Author

@gfyoung gfyoung Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Linux, it means "abort immediately if list is empty." Without that flag, I end up style-checking all Python files in the pandas repository.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I c, ok then.

@jreback jreback added the Docs label Mar 20, 2017
@jreback jreback added this to the 0.20.0 milestone Mar 20, 2017
OSX xargs has no -r, but it still terminates
when xargs is empty, which was the whole point
of passing in that flag in the first place.

[ci skip]
@gfyoung gfyoung force-pushed the flake8-diff-patch branch from 0ea390d to d1543b5 Compare March 20, 2017 19:23
@jreback
Copy link
Contributor

jreback commented Mar 20, 2017

thanks!

@jreback jreback closed this in 2b45e44 Mar 20, 2017
@gfyoung gfyoung deleted the flake8-diff-patch branch March 21, 2017 00:39
AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this pull request Mar 21, 2017
The grep was initially matching to "pandas," which is incorrect
because that was also matching files containing "pandas" in the name
but that were not in the main `pandas` directory (e.g. performance
test code).  This change enforces that we match to any Python files in
the main `pandas` directory.    Also picked up compatibility issue
with OSX, in which the `-r` flag does not exist.  However, `xargs`
terminates if the argument list is empty, which was the whole point of
passing in `-r` in the first place.    Follow-up to pandas-dev#15712

Author: gfyoung <[email protected]>

Closes pandas-dev#15749 from gfyoung/flake8-diff-patch and squashes the following commits:

d1543b5 [gfyoung] COMPAT: Do not run xargs with -r on OSX
da57857 [gfyoung] DOC: Patch new flake8 command grep
gfyoung added a commit to forking-repos/pandas that referenced this pull request Mar 21, 2017
jreback pushed a commit that referenced this pull request Mar 21, 2017
mattip pushed a commit to mattip/pandas that referenced this pull request Apr 3, 2017
The grep was initially matching to "pandas," which is incorrect
because that was also matching files containing "pandas" in the name
but that were not in the main `pandas` directory (e.g. performance
test code).  This change enforces that we match to any Python files in
the main `pandas` directory.    Also picked up compatibility issue
with OSX, in which the `-r` flag does not exist.  However, `xargs`
terminates if the argument list is empty, which was the whole point of
passing in `-r` in the first place.    Follow-up to pandas-dev#15712

Author: gfyoung <[email protected]>

Closes pandas-dev#15749 from gfyoung/flake8-diff-patch and squashes the following commits:

d1543b5 [gfyoung] COMPAT: Do not run xargs with -r on OSX
da57857 [gfyoung] DOC: Patch new flake8 command grep
mattip pushed a commit to mattip/pandas that referenced this pull request Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants