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

Enable pydocstyle rules involving quotes #10748

Merged
merged 3 commits into from
Apr 29, 2022
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: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright (c) 2019-2022, NVIDIA CORPORATION.

repos:
- repo: https://github.com/PyCQA/isort
rev: 5.6.4
Expand Down Expand Up @@ -56,6 +58,19 @@ repos:
hooks:
- id: pydocstyle
args: ["--config=python/.flake8"]
exclude: |
(?x)^(
ci|
cpp|
conda|
docs|
java|
notebooks|
python/dask_cudf|
python/cudf_kafka|
python/custreamz|
python/cudf/cudf/tests
)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v11.1.0
hooks:
Expand Down
24 changes: 12 additions & 12 deletions python/.flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION.
# Copyright (c) 2020-2022, NVIDIA CORPORATION.

[flake8]
exclude = __init__.py
Expand All @@ -9,14 +9,14 @@ ignore =
E203

[pydocstyle]
match = ^(.*abc\.py|.*api/types\.py|.*single_column_frame\.py|.*indexed_frame\.py)$
# Due to https://github.com/PyCQA/pydocstyle/issues/363, we must exclude rather than include using match-dir.
match-dir = ^(?!ci|cpp|python/dask_cudf|python/cudf_kafka|python/custreamz).*$
# In addition to numpy style, we additionally ignore:
add-ignore =
# magic methods
D105,
# no docstring in __init__
D107,
# newlines before docstrings
D204
# Due to https://github.com/PyCQA/pydocstyle/issues/363, we must exclude rather
# than include using match-dir. Note that as discussed in
# https://stackoverflow.com/questions/65478393/how-to-filter-directories-using-the-match-dir-flag-for-pydocstyle,
# unlike the match option above this match-dir will have no effect when
# pydocstyle is invoked from pre-commit. Therefore this exclusion list must
# also be maintained in the pre-commit config file.
match-dir = ^(?!(ci|cpp|conda|docs|java|notebooks|dask_cudf|cudf_kafka|custreamz|tests)).*$
# Allow missing docstrings for docutils
ignore-decorators = .*(docutils|doc_apply|copy_docstring).*
select =
D30
4 changes: 2 additions & 2 deletions python/cudf/cudf/comm/gpuarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def null(self):

@property
def data_raw(self):
"Accessor for the data buffer as a device array"
"""Accessor for the data buffer as a device array"""
return self._series._column.data_array_view

@property
def null_raw(self):
"Accessor for the null buffer as a device array"
"""Accessor for the null buffer as a device array"""
return self._series._column.mask_array_view

def make_series(self):
Expand Down
66 changes: 33 additions & 33 deletions python/cudf/cudf/core/column/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def __getitem__(self, key):
return self.get(key)

def len(self) -> SeriesOrIndex:
"""
r"""
Computes the length of each element in the Series/Index.

Returns
Expand All @@ -213,7 +213,7 @@ def len(self) -> SeriesOrIndex:
Examples
--------
>>> import cudf
>>> s = cudf.Series(["dog", "", "\\n", None])
>>> s = cudf.Series(["dog", "", "\n", None])
>>> s.str.len()
0 3
1 0
Expand Down Expand Up @@ -960,7 +960,7 @@ def replace(
)

def replace_with_backrefs(self, pat: str, repl: str) -> SeriesOrIndex:
"""
r"""
Use the ``repl`` back-ref template to create a new string
with the extracted elements found using the ``pat`` expression.

Expand All @@ -980,7 +980,7 @@ def replace_with_backrefs(self, pat: str, repl: str) -> SeriesOrIndex:
--------
>>> import cudf
>>> s = cudf.Series(["A543","Z756"])
>>> s.str.replace_with_backrefs('(\\\\d)(\\\\d)', 'V\\\\2\\\\1')
>>> s.str.replace_with_backrefs('(\\d)(\\d)', 'V\\2\\1')
0 AV453
1 ZV576
dtype: object
Expand Down Expand Up @@ -1195,7 +1195,7 @@ def istimestamp(self, format: str) -> SeriesOrIndex:
)

def isfloat(self) -> SeriesOrIndex:
"""
r"""
Check whether all characters in each string form floating value.

If a string has zero characters, False is returned for
Expand Down Expand Up @@ -1249,7 +1249,7 @@ def isfloat(self) -> SeriesOrIndex:
4 True
5 False
dtype: bool
>>> s = cudf.Series(["this is plain text", "\\t\\n", "9.9", "9.9.9"])
>>> s = cudf.Series(["this is plain text", "\t\n", "9.9", "9.9.9"])
>>> s.str.isfloat()
0 False
1 False
Expand Down Expand Up @@ -2239,7 +2239,7 @@ def get(self, i: int = 0) -> SeriesOrIndex:
return self._return_or_inplace(libstrings.get(self._column, i))

def get_json_object(self, json_path):
"""
r"""
Applies a JSONPath string to an input strings column
where each row in the column is a valid json string

Expand All @@ -2258,7 +2258,7 @@ def get_json_object(self, json_path):
>>> import cudf
>>> s = cudf.Series(
[
\\"\\"\\"
\"\"\"
{
"store":{
"book":[
Expand All @@ -2277,13 +2277,13 @@ def get_json_object(self, json_path):
]
}
}
\\"\\"\\"
\"\"\"
])
>>> s
0 {"store": {\\n "book": [\\n { "cat...
0 {"store": {\n "book": [\n { "cat...
dtype: object
>>> s.str.get_json_object("$.store.book")
0 [\\n { "category": "reference",\\n ...
0 [\n { "category": "reference",\n ...
dtype: object
"""

Expand Down Expand Up @@ -3138,7 +3138,7 @@ def rjust(self, width: int, fillchar: str = " ") -> SeriesOrIndex:
)

def strip(self, to_strip: str = None) -> SeriesOrIndex:
"""
r"""
Remove leading and trailing characters.

Strip whitespaces (including newlines) or a set of
Expand Down Expand Up @@ -3169,11 +3169,11 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex:
Examples
--------
>>> import cudf
>>> s = cudf.Series(['1. Ant. ', '2. Bee!\\n', '3. Cat?\\t', None])
>>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None])
>>> s
0 1. Ant.
1 2. Bee!\\n
2 3. Cat?\\t
1 2. Bee!\n
2 3. Cat?\t
3 <NA>
dtype: object
>>> s.str.strip()
Expand All @@ -3182,7 +3182,7 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex:
2 3. Cat?
3 <NA>
dtype: object
>>> s.str.strip('123.!? \\n\\t')
>>> s.str.strip('123.!? \n\t')
0 Ant
1 Bee
2 Cat
Expand All @@ -3197,7 +3197,7 @@ def strip(self, to_strip: str = None) -> SeriesOrIndex:
)

def lstrip(self, to_strip: str = None) -> SeriesOrIndex:
"""
r"""
Remove leading and trailing characters.

Strip whitespaces (including newlines)
Expand Down Expand Up @@ -3228,11 +3228,11 @@ def lstrip(self, to_strip: str = None) -> SeriesOrIndex:
Examples
--------
>>> import cudf
>>> s = cudf.Series(['1. Ant. ', '2. Bee!\\n', '3. Cat?\\t', None])
>>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None])
>>> s.str.lstrip('123.')
0 Ant.
1 Bee!\\n
2 Cat?\\t
1 Bee!\n
2 Cat?\t
3 <NA>
dtype: object
"""
Expand All @@ -3244,7 +3244,7 @@ def lstrip(self, to_strip: str = None) -> SeriesOrIndex:
)

def rstrip(self, to_strip: str = None) -> SeriesOrIndex:
"""
r"""
Remove leading and trailing characters.

Strip whitespaces (including newlines)
Expand Down Expand Up @@ -3277,14 +3277,14 @@ def rstrip(self, to_strip: str = None) -> SeriesOrIndex:
Examples
--------
>>> import cudf
>>> s = cudf.Series(['1. Ant. ', '2. Bee!\\n', '3. Cat?\\t', None])
>>> s = cudf.Series(['1. Ant. ', '2. Bee!\n', '3. Cat?\t', None])
>>> s
0 1. Ant.
1 2. Bee!\\n
2 3. Cat?\\t
1 2. Bee!\n
2 3. Cat?\t
3 <NA>
dtype: object
>>> s.str.rstrip('.!? \\n\\t')
>>> s.str.rstrip('.!? \n\t')
0 1. Ant
1 2. Bee
2 3. Cat
Expand All @@ -3299,7 +3299,7 @@ def rstrip(self, to_strip: str = None) -> SeriesOrIndex:
)

def wrap(self, width: int, **kwargs) -> SeriesOrIndex:
"""
r"""
Wrap long strings in the Series/Index to be formatted in
paragraphs with length less than a given width.

Expand Down Expand Up @@ -3340,8 +3340,8 @@ def wrap(self, width: int, **kwargs) -> SeriesOrIndex:
>>> data = ['line to be wrapped', 'another line to be wrapped']
>>> s = cudf.Series(data)
>>> s.str.wrap(12)
0 line to be\\nwrapped
1 another line\\nto be\\nwrapped
0 line to be\nwrapped
1 another line\nto be\nwrapped
dtype: object
"""
if not is_integer(width):
Expand Down Expand Up @@ -3575,7 +3575,7 @@ def isempty(self) -> SeriesOrIndex:
return self._return_or_inplace((self._column == "").fillna(False))

def isspace(self) -> SeriesOrIndex:
"""
r"""
Check whether all characters in each string are whitespace.

This is equivalent to running the Python string method
Expand Down Expand Up @@ -3623,7 +3623,7 @@ def isspace(self) -> SeriesOrIndex:
Examples
--------
>>> import cudf
>>> s = cudf.Series([' ', '\\t\\r\\n ', ''])
>>> s = cudf.Series([' ', '\t\r\n ', ''])
>>> s.str.isspace()
0 True
1 True
Expand Down Expand Up @@ -4271,7 +4271,7 @@ def normalize_spaces(self) -> SeriesOrIndex:
)

def normalize_characters(self, do_lower: bool = True) -> SeriesOrIndex:
"""
r"""
Normalizes strings characters for tokenizing.

This uses the normalizer that is built into the
Expand All @@ -4280,7 +4280,7 @@ def normalize_characters(self, do_lower: bool = True) -> SeriesOrIndex:
- adding padding around punctuation (unicode category starts with
"P") as well as certain ASCII symbols like "^" and "$"
- adding padding around the CJK Unicode block characters
- changing whitespace (e.g. ``\\t``, ``\\n``, ``\\r``) to space
- changing whitespace (e.g. ``\t``, ``\n``, ``\r``) to space
- removing control characters (unicode categories "Cc" and "Cf")

If `do_lower_case = true`, lower-casing also removes the accents.
Expand All @@ -4303,7 +4303,7 @@ def normalize_characters(self, do_lower: bool = True) -> SeriesOrIndex:
Examples
--------
>>> import cudf
>>> ser = cudf.Series(["héllo, \\tworld","ĂĆCĖÑTED","$99"])
>>> ser = cudf.Series(["héllo, \tworld","ĂĆCĖÑTED","$99"])
>>> ser.str.normalize_characters()
0 hello , world
1 accented
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3356,7 +3356,7 @@ def to_dlpack(self):

@_cudf_nvtx_annotate
def to_string(self):
"""
r"""
Convert to string

cuDF uses Pandas internals for efficient string formatting.
Expand All @@ -3373,7 +3373,7 @@ def to_string(self):
>>> df['key'] = [0, 1, 2]
>>> df['val'] = [float(i + 10) for i in range(3)]
>>> df.to_string()
' key val\\n0 0 10.0\\n1 1 11.0\\n2 2 12.0'
' key val\n0 0 10.0\n1 1 11.0\n2 2 12.0'
"""
return repr(self)

Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4614,13 +4614,13 @@ def _align_indices(series_list, how="outer", allow_non_unique=False):

@_cudf_nvtx_annotate
def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False):
"""Returns a boolean array where two arrays are equal within a tolerance.
r"""Returns a boolean array where two arrays are equal within a tolerance.

Two values in ``a`` and ``b`` are considered equal when the following
equation is satisfied.

.. math::
|a - b| \\le \\mathrm{atol} + \\mathrm{rtol} |b|
|a - b| \le \mathrm{atol} + \mathrm{rtol} |b|

Parameters
----------
Expand Down