Skip to content

Commit

Permalink
Use ruff pydocstyle over pydocstyle pre-commit hook (#15345)
Browse files Browse the repository at this point in the history
Most rules were able to translate over except `D302` (`Use u”“” for Unicode docstrings`), which is probably not needed anymore

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Lawrence Mitchell (https://github.com/wence-)

URL: #15345
  • Loading branch information
mroeschke authored Mar 21, 2024
1 parent 691ebb7 commit ebd2ce7
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 34 deletions.
12 changes: 0 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ repos:
"python/cudf_kafka/cudf_kafka",
"python/dask_cudf/dask_cudf"]
pass_filenames: false
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
# https://github.com/PyCQA/pydocstyle/issues/603
additional_dependencies: [tomli]
args: ["--config=pyproject.toml"]
exclude: |
(?x)^(
^python/cudf/cudf/pandas/scripts/.*|
^python/cudf/cudf_pandas_tests/.*
)
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
hooks:
Expand Down
2 changes: 0 additions & 2 deletions docs/cudf/source/developer_guide/contributing_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ The `.pre-commit-config.yaml` file at the root of the repo is the primary source
Specifically, cuDF uses the following tools:

- [`ruff`](https://beta.ruff.rs/) checks for general code formatting compliance.
- [`black`](https://github.com/psf/black) is an automatic code formatter.
- [`isort`](https://pycqa.github.io/isort/) ensures imports are sorted consistently.
- [`mypy`](http://mypy-lang.org/) performs static type checking.
In conjunction with [type hints](https://docs.python.org/3/library/typing.html),
`mypy` can help catch various bugs that are otherwise difficult to find.
- [`pydocstyle`](https://github.com/PyCQA/pydocstyle/) lints docstring style.
- [`codespell`](https://github.com/codespell-project/codespell) finds spelling errors.

Linter config data is stored in a number of files.
Expand Down
2 changes: 1 addition & 1 deletion docs/cudf/source/developer_guide/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Our guidelines include one addition to the standard the `numpydoc` guide.
Class properties, which are not explicitly covered, should be documented in the getter function.
That choice makes `help` more useful as well as enabling docstring inheritance in subclasses.

All of our docstrings are validated using [`pydocstyle`](http://www.pydocstyle.org/en/stable/).
All of our docstrings are validated using [`ruff pydocstyle rules`](https://docs.astral.sh/ruff/rules/#pydocstyle-d).
This ensures that docstring style is consistent and conformant across the codebase.

## Published documentation
Expand Down
18 changes: 3 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# Copyright (c) 2019-2024, NVIDIA CORPORATION.

[tool.pydocstyle]
# 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|python/cudf/cudf/pandas/scripts|python/cudf/cudf_pandas_tests)).*$"
# Allow missing docstrings for docutils
ignore-decorators = ".*(docutils|doc_apply|copy_docstring).*"
select = "D201, D204, D206, D207, D208, D209, D210, D211, D214, D215, D300, D301, D302, D403, D405, D406, D407, D408, D409, D410, D411, D412, D414, D418"
# Would like to enable the following rules in the future:
# D200, D202, D205, D400

[tool.mypy]
ignore_missing_imports = true
# If we don't specify this, then mypy will check excluded files if
Expand All @@ -38,7 +24,7 @@ builtin = "clear"
quiet-level = 3

[tool.ruff]
select = ["E", "F", "W"]
select = ["E", "F", "W", "D201", "D204", "D206", "D207", "D208", "D209", "D210", "D211", "D214", "D215", "D300", "D301", "D403", "D405", "D406", "D407", "D408", "D409", "D410", "D411", "D412", "D414", "D418"]
ignore = [
# whitespace before :
"E203",
Expand All @@ -55,3 +41,5 @@ line-length = 79
[tool.ruff.per-file-ignores]
# Lots of pytest implicitly injected attributes in conftest-patch.py
"python/cudf/cudf/pandas/scripts/conftest-patch.py" = ["F821"]
"python/cudf/cudf/pandas/scripts/*" = ["D"]
"python/cudf/cudf_pandas_tests/*" = ["D"]
2 changes: 2 additions & 0 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -2382,10 +2382,12 @@ def serialize_columns(columns) -> Tuple[List[dict], List]:
"""
Return the headers and frames resulting
from serializing a list of Column
Parameters
----------
columns : list
list of Columns to serialize
Returns
-------
headers : list
Expand Down
3 changes: 1 addition & 2 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4798,7 +4798,6 @@ def apply_chunks(
Examples
--------
For ``tpb > 1``, ``func`` is executed by ``tpb`` number of threads
concurrently. To access the thread id and count,
use ``numba.cuda.threadIdx.x`` and ``numba.cuda.blockDim.x``,
Expand All @@ -4824,7 +4823,7 @@ def apply_chunks(
... z = in3[i]
... out1[i] = x * y + z
See also
See Also
--------
DataFrame.apply_rows
"""
Expand Down
4 changes: 3 additions & 1 deletion python/cudf/cudf/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@


def _align_objs(objs, how="outer", sort=None):
"""Align a set of Series or Dataframe objects.
"""
Align a set of Series or Dataframe objects.
Parameters
----------
objs : list of DataFrame, Series, or Index
how : How to handle indexes on other axis (or axes),
similar to join in concat
sort : Whether to sort the resulting Index
Returns
-------
A list of reindexed and aligned objects
Expand Down
1 change: 1 addition & 0 deletions python/cudf/cudf/utils/ioutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,7 @@ def stringify_pathlike(pathlike):
"""
Convert any object that implements the fspath protocol
to a string. Leaves other objects unchanged
Parameters
----------
pathlike
Expand Down
5 changes: 4 additions & 1 deletion python/dask_cudf/dask_cudf/accessors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, NVIDIA CORPORATION.


class StructMethods:
Expand All @@ -9,14 +9,17 @@ def field(self, key):
"""
Extract children of the specified struct column
in the Series
Parameters
----------
key: int or str
index/position or field name of the respective
struct column
Returns
-------
Series
Examples
--------
>>> s = cudf.Series([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}])
Expand Down

0 comments on commit ebd2ce7

Please sign in to comment.