-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Integrate flake8_rst into ./ci/code_check.sh #23381
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
Changes from 11 commits
8325caf
226bc53
472df59
11a3632
7fd215d
d1be499
acea30a
bc6d6f7
77df97f
67cf043
f440c63
948f176
c01e22d
816f26e
1a4c6fe
ed17b45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ Cython>=0.28.2 | |
NumPy | ||
flake8 | ||
flake8-comprehensions | ||
flake8-rst | ||
hypothesis>=3.58.0 | ||
isort | ||
moto | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,18 +306,18 @@ To evaluate single-element pandas objects in a boolean context, use the method | |
|
||
.. code-block:: python | ||
|
||
>>> if df: | ||
... | ||
>>> if df: # noqa: E999 | ||
... | ||
|
||
Or | ||
|
||
.. code-block:: python | ||
|
||
>>> df and df2 | ||
>>> df and df2 # noqa: E999 | ||
|
||
These will both raise errors, as you are trying to compare multiple values. | ||
|
||
.. code-block:: python | ||
.. code-block:: console | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 didn't know that directive. |
||
|
||
ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all(). | ||
|
||
|
@@ -732,9 +732,8 @@ with the equivalent | |
.. code-block:: python | ||
|
||
>>> (df.pipe(h) | ||
.pipe(g, arg1=1) | ||
.pipe(f, arg2=2, arg3=3) | ||
) | ||
... .pipe(g, arg1=1) | ||
... .pipe(f, arg2=2, arg3=3)) | ||
|
||
Pandas encourages the second style, which is known as method chaining. | ||
``pipe`` makes it easy to use your own or another library's functions | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -744,15 +744,15 @@ Transitioning to ``pytest`` | |
.. code-block:: python | ||
|
||
class TestReallyCoolFeature(object): | ||
.... | ||
.... # noqa: E999 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd Would you prefer a |
||
|
||
Going forward, we are moving to a more *functional* style using the `pytest <http://docs.pytest.org/en/latest/>`__ framework, which offers a richer testing | ||
framework that will facilitate testing and developing. Thus, instead of writing test classes, we will write test functions like this: | ||
|
||
.. code-block:: python | ||
|
||
def test_really_cool_feature(): | ||
.... | ||
.... # noqa: E999 | ||
|
||
Using ``pytest`` | ||
~~~~~~~~~~~~~~~~ | ||
|
@@ -777,25 +777,30 @@ We would name this file ``test_cool_feature.py`` and put in an appropriate place | |
import pandas as pd | ||
from pandas.util import testing as tm | ||
|
||
|
||
@pytest.mark.parametrize('dtype', ['int8', 'int16', 'int32', 'int64']) | ||
def test_dtypes(dtype): | ||
assert str(np.dtype(dtype)) == dtype | ||
|
||
@pytest.mark.parametrize('dtype', ['float32', | ||
pytest.param('int16', marks=pytest.mark.skip), | ||
pytest.param('int32', | ||
marks=pytest.mark.xfail(reason='to show how it works'))]) | ||
|
||
@pytest.mark.parametrize( | ||
'dtype', ['float32', pytest.param('int16', marks=pytest.mark.skip), | ||
pytest.param('int32', marks=pytest.mark.xfail( | ||
reason='to show how it works'))]) | ||
def test_mark(dtype): | ||
assert str(np.dtype(dtype)) == 'float32' | ||
|
||
|
||
@pytest.fixture | ||
def series(): | ||
return pd.Series([1, 2, 3]) | ||
|
||
|
||
@pytest.fixture(params=['int8', 'int16', 'int32', 'int64']) | ||
def dtype(request): | ||
return request.param | ||
|
||
|
||
def test_series(series, dtype): | ||
result = series.astype(dtype) | ||
assert result.dtype == dtype | ||
|
@@ -864,6 +869,7 @@ for details <https://hypothesis.readthedocs.io/en/latest/index.html>`_. | |
st.lists(any_json_value), st.dictionaries(st.text(), any_json_value) | ||
)) | ||
|
||
|
||
@given(value=any_json_value) | ||
def test_json_roundtrip(value): | ||
result = json.loads(json.dumps(value)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally what kind of E999 errors are you getting? Not terribly familiar with this code but seems to come as a result of AST issues, but am wondering if that's more of a Python versioning issue than an actual styling violation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the
and
tricked me into thinking it was an if-statement like a couple of lines above.