Skip to content

Commit 9e96d67

Browse files
authored
[DOC/TST] New docstring testing package darglint (pyjanitor-devs#758)
* [INF] initial commit of .darglint file * [INF] add darglint to requirements-dev.txt and pre-commit hooks * [INF] update darglint pre-commit hook to use verbosity of 2 * [DOC] update functions.move() docstring with typehint references and raise clauses * [DOC] update tests/functions/test_also.drop_inplace() to ignore darglint checking * [DOC] update scripts/check-autodoc.extract_folder_names() to be single line docstring for darglint * [DOC] update janitor/spark/backend register_dataframe funcs to ignore darglint checking * [DOC] update janitor/testing_utils/strategies.df_strategy() to ignore darglint checking * [DOC] update math.ecdf() with raise clauses * [DOC/FIX] update functions.move() to encapsulate raise clauses with raise type * [DOC] update janitor/xarray/functions.clone_using() docstring with raise clauses * [DOC] update janitor/math.py with darglint docstrings * math.log() to ignore ``error`` as optional input * math.sigmoid() to ignore multi-line docstring * math.logit() to ignore ``error`` as optional input * math.logit() to include ``raises`` clause * math.probit() to ignore ``error`` as optional input * math.z_score() to ignore ``moments_dict`` as optional input * [DOC/FIX] add double space for noqa statements in docstrings * [DOC] update engineering.convert_units with raise clause * [DOC] update chemistry.morgan_fingerprint() with raise clause * [DOC] update chemistry.smiles2mol() with raise clause * [DOC] update utils.py with raise clauses * [DOC] update setup.pt generate_long_description() with raise clause * [DOC] update tests/xarray/contest.py da() docstring to ignore darglint * [DOC] upates finance.py docstrings with return clauses * [DOC] upate get_feature_targets() docstring in ml.py to not reference arg types * [DOC] update read_csvs() docstring in io.py with return and raises clauses * [DOC] update complete() docstring in functions.py to encapsulate raise clauses in colons * [DOC] update groupby_topk() docstring in functions.py to encapsulate raise clauses in colons * [DOC] update fill_direction() docstring in functions.py to encapsulate raise clauses in colons * [DOC] update process_text() docstring in functions.py to encapsulate raise clauses in colons and include arg, kwarg, str_function params * [DOC] test if noqa shows up in docs build * [DOC] try to hide noqa with .. * [DOC] try to hide noqa with .. and new line * [DOC] upadte darglint ignores in docstiong with new line and preceeding .. so ignores dont show up in docs * [DOC] update expand_grid() docstring in functions.py to encapsulate raise clauses in colons * [DOC] update sort_naturally() docstring in functions.py with returns clause * [DOC] update jitter() docstring in functions.py with raise clauses * [DOC] update join_apply() docstring in functions.py with returns clause * [DOC] update shuffle() docstring in functions.py with returns clause * [DOC] update drop_duplicate_columns() docstring in functions.py with 4 space indent * [DOC] update bin_numeric() docstring in functions.py with raises clause * [DOC] update DataDescitption.set_description() docstring in functions.py with raises clause * [DOC] update groupby_agg() docstring in functions.py by deletiing axis param * [DOC] update find_replace() docstring in functions.py with returns clause * [DOC] update also() docstring in functions.py with args and kwargs param clauses * [DOC] update iimpute() docstring in functions.py with raise clauses * [DOC] update select_columns() docstring in functions.py with raise clauses * [DOC] update min_max_scale() docstring in functions.py and ValueError * [DOC] update transform_columns() docstring in functions.py with raises clause * [DOC] update add_column() docstring in functions.py with raise clauses and update ValueError messages * [DOC] update change_type() docstring in functions.py with raise clause * [DOC] update filter_column_isin() docstring in functions.py with raises clause * [DOC] update deconcatenate_column() docstring in functions.py with raises clause * [DOC] update concatenate_columns() docstring in functions.py with raise clause * [DOC] update expand_column() docstring in functions.py to leave out type defn for concat param * [DOC] update fill_empty() docstring in functions.py with raises clause * [DOC] update convert_unix_date() docstring in functions.py to leave out type defn for column_name param * [DOC] update convert_matlab_date() docstring in functions.py to leave out type defn for column_name param * [DOC] update convert_excel_date() docstring in functions.py to leave out type defn for column_name param * [DOC] update convert_excel_date() docstring in functions.py to leave out type defn for params * [DOC] update reorder_columns() docstring in functions.py with raises clause * [FIX] change typo in reorder_columns() raises clause * [DOC] update label_encode() docstring in functions.py with raise clauses * [DOC] update encode_categorical() docstring in functions.py with raise clauses * [DOC] update get_dupes() docstring in functions.py to leave out type defn for column_name param * [DOC] update clean_names() docstring in functions.py with strip_accents param * [DOC] update unionize_dataframe_categories() in functions.py with raises clause * [INF] remove .darglint file and move configs to pyproject.toml * [INF] delete .darglint file * [INF/FIX] wrap darglint configs in quotes * [INF/FIX] fix quote typo * [INF] revert back to .dargline file as docs say must exist in repo * [FIX] .darglint should have not str values * [DOC] add param and return to functions.patterns() * [DOC] add line to changelog * [DOC] add comment to pre-commit configs explaining darglint args * [FIX] line 1118 in functions.py causes pipeline fail; line too long * [INF] add darglint to run-tests.yml * [INF/FIX] fix typo in run-tests.yml for darglint step...doh * [INF] sort requirements-dev.txt * [INF] add darglint; remove duplicate pandas-vet from requirements.txt * [DOC] update changelog after new release
1 parent 9b3de9b commit 9e96d67

21 files changed

+214
-82
lines changed

.azure-pipelines/templates/run-tests.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ steps:
1010
- script: |
1111
$(activate.command) pyjanitor-dev
1212
interrogate
13-
displayName: 'Docstring coverage'
13+
displayName: 'Docstring coverage: interrogate'
14+
- script: |
15+
$(activate.command) pyjanitor-dev
16+
darglint janitor -v 2
17+
displayName: 'Docstring linter: darglint'
1418
- script: |
1519
$(activate.command) pyjanitor-dev
1620
pytest

.darglint

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[darglint]
2+
docstring_style=sphinx
3+
strictness=short
4+
ignore_regex=^(test_|_)(.*)

.pre-commit-config.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@ repos:
2121
- repo: https://github.com/econchick/interrogate
2222
rev: 1.1.5
2323
hooks:
24-
- id: interrogate
25-
args: [-c, pyproject.toml]
24+
- id: interrogate
25+
args: [-c, pyproject.toml]
26+
- repo: https://github.com/terrencepreilly/darglint
27+
rev: master
28+
hooks:
29+
- id: darglint
30+
args: [-v 2] # this config makes the error messages a bit less cryptic.

CHANGELOG.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
new version (on deck)
22
=====================
3+
- [INF] Deploy ``darglint`` package for docstring linting. Issue #745. @loganthomas
4+
5+
6+
v0.20.10
7+
=======
38
- [ENH] Added function ``sort_timestamps_monotonically`` to timeseries functions @UGuntupalli
49
- [ENH] Added the complete function for converting implicit missing values
510
to explicit ones. @samukweku
611
- [ENH] Further simplification of expand_grid. @samukweku
712
- [BUGFIX] Added copy() method to original dataframe, to avoid mutation. Issue #729. @samukweku
813
- [ENH] Added `also` method for running functions in chain with no return values.
914
- [DOC] Added a ``timeseries`` module section to website docs. Issue #742. @loganthomas
10-
- [ENH] Added a `pivot_longer` function, a wrapper around ``pd.melt`` and similar to
15+
- [ENH] Added a `pivot_longer` function, a wrapper around ``pd.melt`` and similar to
1116
tidyr's ``pivot_longer`` function. Also added an example notebook. @samukweku
1217
- [ENH] Fixed code to returns error if `fill_value` is not a dictionary. @samukweku
1318
- [INF] Welcome bot (.github/config.yml) for new users added. Issue #739. @samukweku
1419

20+
1521
v0.20.9
1622
=======
1723
- [ENH] Updated groupby_agg function to account for null entries in the ``by`` argument. @samukweku
1824
- [ENH] Added function ``groupby_topk`` to janitor functions @mphirke
1925

26+
2027
v0.20.8
2128
=======
2229
- [ENH] Upgraded ``update_where`` function to use either the pandas query style,
@@ -38,7 +45,6 @@ v0.20.8
3845
- [ENH] Simpler logic and less lines of code for expand_grid function @samukweku
3946

4047

41-
4248
v0.20.7
4349
=======
4450
- [TST] Add a test for transform_column to check for nonmutation. @VPerrollaz
@@ -61,11 +67,13 @@ v0.20.5
6167
- [ENH] ``select_columns()`` now raises ``NameError`` if column label in
6268
``search_columns_labels`` is missing from ``DataFrame`` columns. @smu095
6369

70+
6471
v0.20.1
6572
=======
6673
- [DOC] Added an example for groupby_agg in general functions @samukweku
6774
- [ENH] Contributed ``sort_naturally()`` function. @ericmjl
6875

76+
6977
v0.20.0
7078
=======
7179
- [DOC] Edited transform_column dest_column_name kwarg description to be clearer on defaults by @evan-anderson.
@@ -76,6 +84,7 @@ v0.20.0
7684
- [ENH] Change ``find_replace`` implementation to use keyword arguments to specify columns to perform find and replace on. @ericmjl
7785
- [ENH] Add ``jitter()`` dataframe function by @rahosbach
7886

87+
7988
v0.19.0
8089
=======
8190
- [ENH] Add xarray support and clone_using / convert_datetime_to_number funcs by @zbarry.
@@ -96,6 +105,7 @@ v0.18.3
96105
- [DOC] Changed the typing for most "column_name(s)" to Hashable rather than enforcing strings, to more closely match Pandas API by @dendrondal
97106
- [INF] Edited pycodestyle and Black parameters to avoid venvs by @dendrondal
98107

108+
99109
v0.18.2
100110
=======
101111
- [INF] Make requirements.txt smaller @eyaltrabelsi
@@ -117,6 +127,7 @@ v0.18.2
117127
- [ENH] Add count_cumulative_unique() method to janitor.functions submodule by @rahosbach
118128
- [ENH] Add ``update_where()`` method to ``janitor.spark.functions`` submodule by @zjpoh
119129

130+
120131
v0.18.1
121132
=======
122133
- [ENH] extend find_replace functionality to allow both exact match and

janitor/chemistry.py

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def smiles2mol(
134134
constructed.
135135
:param progressbar: Whether to show a progressbar or not.
136136
:returns: A pandas DataFrame with new RDKIT Mol objects column.
137+
:raises ValueError: if ``progressbar`` is not one of
138+
``"notebook"``, ``"terminal"``, or ``None``.
137139
"""
138140
valid_progress = ["notebook", "terminal", None]
139141
if progressbar not in valid_progress:
@@ -247,6 +249,8 @@ def morgan_fingerprint(
247249
:param nbits: The length of the fingerprints. Defaults to 2048.
248250
:param kind: Whether to return counts or bits. Defaults to counts.
249251
:returns: A new pandas DataFrame of Morgan fingerprints.
252+
:raises ValueError: if ``kind`` is not one of
253+
``"counts"`` or ``"bits"``.
250254
"""
251255
acceptable_kinds = ["counts", "bits"]
252256
if kind not in acceptable_kinds:

janitor/engineering.py

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def convert_units(
8787
converted values that will be created.
8888
8989
:returns: A pandas DataFrame with a new column of unit-converted values.
90+
:raises TypeError: if column is not numeric.
9091
"""
9192

9293
# Check all inputs are correct data type

janitor/finance.py

+2
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def convert_currency(
433433
rates go back to Jan. 4, 1999.
434434
:param make_new_column: Generates new column for converted currency if
435435
True, otherwise, converts currency in place.
436+
:returns: The dataframe with converted currency column.
436437
437438
:Setup:
438439
@@ -640,6 +641,7 @@ def inflate_currency(
640641
The year should be 1960 or later.
641642
:param make_new_column: Generates new column for inflated currency if
642643
True, otherwise, inflates currency in place.
644+
:returns: The dataframe with inflated currency column.
643645
"""
644646

645647
inflator = _inflate_currency(country, currency_year, to_year)

0 commit comments

Comments
 (0)