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

Lint rule to catch incorrect sphinx directives #18437

Merged
merged 3 commits into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,26 @@ if [ "$LINT" ]; then
#
# Check the following functions:
# any(), all(), sum(), max(), min(), list(), dict(), set(), frozenset(), tuple(), str.join()
grep -R --include="*.py*" -E "[^_](any|all|sum|max|min|list|dict|set|frozenset|tuple|join)\(\[.* for .* in .*\]\)"
grep -R --include="*.py*" -E "[^_](any|all|sum|max|min|list|dict|set|frozenset|tuple|join)\(\[.* for .* in .*\]\)" *
Copy link
Contributor Author

@Scorpil Scorpil Nov 22, 2017

Choose a reason for hiding this comment

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

I added a * in the end because without it this regexp will just wait for stdin (unless linux version works differently. I tried it on mac).

Copy link
Member

Choose a reason for hiding this comment

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

+1. On Linux, it will grep all directories without the *, but for consistency adding * or . is good.


if [ $? = "0" ]; then
RET=1
fi
echo "Check for use of lists instead of generators in built-in Python functions DONE"

echo "Check for incorrect sphinx directives"
SPHINX_DIRECTIVES=$(echo \
"autosummary|contents|currentmodule|deprecated|function|image|"\
"important|include|ipython|literalinclude|math|module|note|raw|"\
"seealso|toctree|versionadded|versionchanged|warning" | tr -d "[:space:]")
for path in './pandas' './doc/source'
do
grep -R --include="*.py" --include="*.pyx" --include="*.rst" -E "\.\. ($SPHINX_DIRECTIVES):[^:]" $path
if [ $? = "0" ]; then
RET=1
fi
done
echo "Check for incorrect sphinx directives DONE"
else
echo "NOT Linting"
fi
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4513,7 +4513,7 @@ def unstack(self, level=-1, fill_value=None):
fill_value : replace NaN with this value if the unstack produces
missing values

.. versionadded: 0.18.0
.. versionadded:: 0.18.0

See also
--------
Expand Down Expand Up @@ -4676,7 +4676,7 @@ def diff(self, periods=1, axis=0):
axis : {0 or 'index', 1 or 'columns'}, default 0
Take difference over rows (0) or columns (1).

.. versionadded: 0.16.1
.. versionadded:: 0.16.1

Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ def append(self, to_append, ignore_index=False, verify_integrity=False):
ignore_index : boolean, default False
If True, do not use the index labels.

.. versionadded: 0.19.0
.. versionadded:: 0.19.0

verify_integrity : boolean, default False
If True, raise Exception on creating index with duplicates
Expand Down Expand Up @@ -2213,7 +2213,7 @@ def unstack(self, level=-1, fill_value=None):
fill_value : replace NaN with this value if the unstack produces
missing values

.. versionadded: 0.18.0
.. versionadded:: 0.18.0

Examples
--------
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
----------
arg : integer, float, string, datetime, list, tuple, 1-d array, Series

.. versionadded: 0.18.1
.. versionadded:: 0.18.1

or DataFrame/dict-like

Expand All @@ -140,7 +140,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
Warning: yearfirst=True is not strict, but will prefer to parse
with year first (this is a known bug, based on dateutil beahavior).

.. versionadded: 0.16.1
.. versionadded:: 0.16.1

utc : boolean, default None
Return UTC DatetimeIndex if True (converting any tz-aware
Expand Down Expand Up @@ -178,13 +178,13 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
- If Timestamp convertible, origin is set to Timestamp identified by
origin.

.. versionadded: 0.20.0
.. versionadded:: 0.20.0
cache : boolean, default False
If True, use a cache of unique, converted dates to apply the datetime
conversion. May produce sigificant speed-up when parsing duplicate date
strings, especially ones with timezone offsets.

.. versionadded: 0.22.0
.. versionadded:: 0.22.0

Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ class BusinessHour(BusinessHourMixin, SingleConstructorOffset):
"""
DateOffset subclass representing possibly n business days

.. versionadded: 0.16.1
.. versionadded:: 0.16.1

"""
_prefix = 'BH'
Expand Down Expand Up @@ -878,7 +878,7 @@ class CustomBusinessHour(BusinessHourMixin, SingleConstructorOffset):
"""
DateOffset subclass representing possibly n custom business days

.. versionadded: 0.18.1
.. versionadded:: 0.18.1

"""
_prefix = 'CBH'
Expand Down