Skip to content

Commit 79c00c0

Browse files
authored
docs: Enable darglint for dataframe and series modules (#2931)
* docs: Enable darglint for dataframe and series modules * docstring to comment
1 parent 69de731 commit 79c00c0

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ repos:
2626
hooks:
2727
- id: flake8
2828
additional_dependencies: [darglint==1.8.1, Flake8-pyproject]
29-
entry: flake8 --select DAR --ignore DAR101,DAR402,DAR401
29+
entry: flake8 --select DAR --ignore DAR101,DAR401,DAR402
3030
exclude: |
3131
(?x)^(
3232
tests/.*|
3333
# TODO: gradually enable
34-
narwhals/series\.py|
35-
# TODO: gradually enable
36-
narwhals/dataframe\.py|
37-
# TODO: gradually enable
3834
narwhals/dependencies\.py|
39-
# private, so less urgent to document too well
35+
# Private, so less urgent to document too well
4036
narwhals/_.*|
37+
# Internal use only, less urgent
4138
^utils/.*|
4239
# Soft-deprecated, so less crucial to document so carefully
4340
narwhals/stable/v1/.*

narwhals/dataframe.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def _with_compliant(self, df: Any) -> Self:
112112
def _flatten_and_extract(
113113
self, *exprs: IntoExpr | Iterable[IntoExpr], **named_exprs: IntoExpr
114114
) -> tuple[list[CompliantExprAny], list[ExprKind]]:
115-
"""Process `args` and `kwargs`, extracting underlying objects as we go, interpreting strings as column names."""
115+
# Process `args` and `kwargs`, extracting underlying objects as we go.
116+
# NOTE: Strings are interpreted as column names.
116117
out_exprs = []
117118
out_kinds = []
118119
for expr in flatten(exprs):
@@ -700,6 +701,9 @@ def __arrow_c_stream__(self, requested_schema: object | None = None) -> object:
700701
701702
See [PyCapsule Interface](https://arrow.apache.org/docs/dev/format/CDataInterface/PyCapsuleInterface.html)
702703
for more.
704+
705+
Returns:
706+
A PyCapsule containing a C ArrowArrayStream representation of the object.
703707
"""
704708
native_frame = self._compliant_frame._native_frame
705709
if supports_arrow_c_stream(native_frame):
@@ -900,9 +904,6 @@ def write_parquet(self, file: str | Path | BytesIO) -> None:
900904
file: String, path object or file-like object to which the dataframe will be
901905
written.
902906
903-
Returns:
904-
None.
905-
906907
Examples:
907908
>>> import pyarrow as pa
908909
>>> import narwhals as nw
@@ -1459,7 +1460,7 @@ def with_columns(
14591460
The columns will be renamed to the keyword used.
14601461
14611462
Returns:
1462-
DataFrame: A new DataFrame with the columns added.
1463+
New DataFrame with the columns added.
14631464
14641465
Note:
14651466
Creating a new DataFrame using this method does not create a new copy of
@@ -2744,7 +2745,7 @@ def with_columns(
27442745
The columns will be renamed to the keyword used.
27452746
27462747
Returns:
2747-
LazyFrame: A new LazyFrame with the columns added.
2748+
New LazyFrame with the columns added.
27482749
27492750
Note:
27502751
Creating a new LazyFrame using this method does not create a new copy of
@@ -3044,9 +3045,6 @@ def sink_parquet(self, file: str | Path | BytesIO) -> None:
30443045
file: String, path object or file-like object to which the dataframe will be
30453046
written.
30463047
3047-
Returns:
3048-
None.
3049-
30503048
Examples:
30513049
>>> import polars as pl
30523050
>>> import narwhals as nw

narwhals/series.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ def __arrow_c_stream__(self, requested_schema: object | None = None) -> object:
268268
269269
See [PyCapsule Interface](https://arrow.apache.org/docs/dev/format/CDataInterface/PyCapsuleInterface.html)
270270
for more.
271+
272+
Returns:
273+
A PyCapsule containing a C ArrowArrayStream representation of the object.
271274
"""
272275
native_series = self._compliant_series.native
273276
if supports_arrow_c_stream(native_series):
@@ -773,6 +776,9 @@ def max(self) -> Any:
773776
def arg_min(self) -> int:
774777
"""Returns the index of the minimum value.
775778
779+
Returns:
780+
The index of the min value in the Series.
781+
776782
Examples:
777783
>>> import pyarrow as pa
778784
>>> import narwhals as nw
@@ -786,6 +792,9 @@ def arg_min(self) -> int:
786792
def arg_max(self) -> int:
787793
"""Returns the index of the maximum value.
788794
795+
Returns:
796+
The index of the max value in the Series.
797+
789798
Examples:
790799
>>> import polars as pl
791800
>>> import narwhals as nw
@@ -819,7 +828,7 @@ def std(self, *, ddof: int = 1) -> float:
819828
820829
Arguments:
821830
ddof: "Delta Degrees of Freedom": the divisor used in the calculation is N - ddof,
822-
where N represents the number of elements.
831+
where N represents the number of elements.
823832
824833
Returns:
825834
The standard deviation of all elements in the Series.
@@ -839,7 +848,10 @@ def var(self, *, ddof: int = 1) -> float:
839848
840849
Arguments:
841850
ddof: "Delta Degrees of Freedom": the divisor used in the calculation is N - ddof,
842-
where N represents the number of elements.
851+
where N represents the number of elements.
852+
853+
Returns:
854+
The variance of all elements in the Series.
843855
844856
Examples:
845857
>>> import pyarrow as pa

0 commit comments

Comments
 (0)