Repository: pyjanitor-devs/pyjanitor

Issue:
[INF] Update pre-commit hook revs
# PR Description

Please describe the changes proposed in the pull request:

- New updates to `pre-commit` now warns users if `rev` fields in the `.pre-commit-config.yaml` file reference mutable objects (moving tags/branch). 
- Suggestion is to use `pre-commit autoupdate`

**This PR resolves #844 .**

Full output below:
```
[WARNING] The 'rev' field of repo 'https://github.com/kynan/nbstripout' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
[WARNING] The 'rev' field of repo 'https://github.com/terrencepreilly/darglint' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.

Updating https://github.com/pre-commit/pre-commit-hooks ... updating v2.4.0 -> v4.0.1.
Updating https://github.com/psf/black ... updating 19.10b0 -> 21.7b0.
Updating https://github.com/kynan/nbstripout ... updating master -> 0.5.0.
Updating https://github.com/econchick/interrogate ... updating 1.1.5 -> 1.4.0.
Updating https://github.com/terrencepreilly/darglint ... updating master -> v1.8.0.
```

# PR Checklist

<!-- This checklist exists for newcomers who are not yet familiar with our requirements. If you are experienced with
the project, please feel free to delete this section. -->

Please ensure that you have done the following:

1. [X] PR in from a fork off your branch. Do not PR from `<your_username>`:`dev`, but rather from `<your_username>`:`<feature-branch_name>`.
<!-- Doing this helps us keep the commit history much cleaner than it would otherwise be. -->
2. [X] If you're not on the contributors list, add yourself to `AUTHORS.rst`.
<!-- We'd like to acknowledge your contributions! -->
3. [X] Add a line to `CHANGELOG.md` under the latest version header (i.e. the one that is "on deck") describing the contribution.
    - Do use some discretion here; if there are multiple PRs that are related, keep them in a single line.

# Automatic checks

There will be automatic checks run on the PR. These include:

- Building a preview of the docs on Netlify
- Automatically linting the code
- Making sure the code is documented
- Making sure that all tests are passed
- Making sure that code coverage doesn't go down.

# Relevant Reviewers

<!-- Finally, please tag relevant maintainers to review. -->

Please tag maintainers to review.

- @ericmjl



Discussion:
Thanks @loganthomas!

Resolving patch:
diff --git a/janitor/functions.py b/janitor/functions.py
--- a/janitor/functions.py
+++ b/janitor/functions.py
@@ -473,7 +473,8 @@ def get_dupes(
 
 
 def As_Categorical(
-    categories: Optional[List] = None, order: Optional[str] = None,
+    categories: Optional[List] = None,
+    order: Optional[str] = None,
 ) -> NamedTuple:
     """
     Helper function for `encode_categorical`. It makes creating the
@@ -3145,7 +3146,9 @@ def currency_column_to_numeric(
 @pf.register_dataframe_method
 @deprecated_alias(search_cols="search_column_names")
 def select_columns(
-    df: pd.DataFrame, *args, invert: bool = False,
+    df: pd.DataFrame,
+    *args,
+    invert: bool = False,
 ) -> pd.DataFrame:
     """
     Method-chainable selection of columns.
diff --git a/janitor/utils.py b/janitor/utils.py
--- a/janitor/utils.py
+++ b/janitor/utils.py
@@ -781,7 +781,11 @@ def _computations_complete(
     # still thinking on how to improve speed of groupby apply
     else:
         df = df.groupby(by).apply(
-            _base_complete, columns, all_strings, any_nulls, dict_present,
+            _base_complete,
+            columns,
+            all_strings,
+            any_nulls,
+            dict_present,
         )
         df = df.drop(columns=by)
 
@@ -829,7 +833,8 @@ def _base_complete(
 
 
 def _create_indexer_for_complete(
-    df_index: pd.Index, columns: List[Union[List, Dict, str]],
+    df_index: pd.Index,
+    columns: List[Union[List, Dict, str]],
 ) -> pd.DataFrame:
     """
     This creates the index that will be used
@@ -1128,7 +1133,10 @@ def _data_checks_pivot_longer(
     check("values_to", values_to, [str])
 
     if (values_to in df.columns) and not any(
-        (".value" in names_to, isinstance(names_pattern, (list, tuple)),)
+        (
+            ".value" in names_to,
+            isinstance(names_pattern, (list, tuple)),
+        )
     ):
         # copied from pandas' melt source code
         # with a minor tweak


Test patch:
diff --git a/tests/functions/test_complete.py b/tests/functions/test_complete.py
--- a/tests/functions/test_complete.py
+++ b/tests/functions/test_complete.py
@@ -689,7 +689,8 @@ def test_complete_groupby():
     )
 
     result = df.complete(
-        columns=[{"year": lambda x: range(x.min(), x.max() + 1)}], by="state",
+        columns=[{"year": lambda x: range(x.min(), x.max() + 1)}],
+        by="state",
     )
 
     expected = pd.DataFrame(
diff --git a/tests/functions/test_convert_excel_date.py b/tests/functions/test_convert_excel_date.py
--- a/tests/functions/test_convert_excel_date.py
+++ b/tests/functions/test_convert_excel_date.py
@@ -22,7 +22,7 @@ def test_convert_excel_date():
 
 @pytest.mark.functions
 def test_convert_excel_date_with_string_data():
-    """ Raises ValueError if values of column are not numeric """
+    """Raises ValueError if values of column are not numeric"""
     df = pd.read_excel(
         Path(pytest.EXAMPLES_DIR) / "notebooks" / "dirty_data.xlsx",
         engine="openpyxl",
diff --git a/tests/functions/test_encode_categorical.py b/tests/functions/test_encode_categorical.py
--- a/tests/functions/test_encode_categorical.py
+++ b/tests/functions/test_encode_categorical.py
@@ -141,7 +141,7 @@ def test_categories_ndim_gt_1_in_kwargs(df_categorical):
 
 def test_categories_null_in_categories(df_categorical):
     """
-     Raise ValueError if there are nulls in the `categories`.
+    Raise ValueError if there are nulls in the `categories`.
     """
     with pytest.raises(ValueError):
         df_categorical.encode_categorical(col1=([None, 2, 3], None))
@@ -419,7 +419,9 @@ def test_various(df_in, df_out, kwargs):
     #     **kwargs,
     # )
     # assert_frame_equal(result, df_out)
-    result = df_in.encode_categorical(**kwargs,)
+    result = df_in.encode_categorical(
+        **kwargs,
+    )
     # directly comparing columns is safe -
     # if the columns have differing categories
     # (especially for ordered True) it will fail.
diff --git a/tests/functions/test_pivot_longer.py b/tests/functions/test_pivot_longer.py
--- a/tests/functions/test_pivot_longer.py
+++ b/tests/functions/test_pivot_longer.py
@@ -379,7 +379,9 @@ def test_pivot_index_only_and_sort_by_appearance(df_checks_output):
 def test_pivot_index_only():
     """Test output if only `index` is passed."""
     result = df_checks.pivot_longer(
-        index="region", names_to="year", values_to="num_nests",
+        index="region",
+        names_to="year",
+        values_to="num_nests",
     )
 
     df_out = pd.DataFrame(
@@ -1251,7 +1253,12 @@ def test_multiple_values_sep(
     paired_columns_pattern,
 )
 def test_extract_column_names_pattern(
-    df_in, df_out, index, names_to, names_pattern, sort_by_appearance,
+    df_in,
+    df_out,
+    index,
+    names_to,
+    names_pattern,
+    sort_by_appearance,
 ):
     """
     Test output if `.value` is in the `names_to`
@@ -1595,7 +1602,12 @@ def test_extract_column_names_pattern(
     paired_columns_sep,
 )
 def test_extract_column_names_sep(
-    df_in, df_out, index, names_to, names_sep, sort_by_appearance,
+    df_in,
+    df_out,
+    index,
+    names_to,
+    names_sep,
+    sort_by_appearance,
 ):
     """
     Test output if `.value` is in the `names_to` argument
@@ -1830,7 +1842,12 @@ def test_paired_columns_no_index_pattern(
     names_single_value,
 )
 def test_single_value(
-    df_in, df_out, index, names_pattern, ignore_index, sort_by_appearance,
+    df_in,
+    df_out,
+    index,
+    names_pattern,
+    ignore_index,
+    sort_by_appearance,
 ):
     """Test function where names_to is a string and == `.value`."""
     result = df_in.pivot_longer(
@@ -1951,7 +1968,9 @@ def test_group_present():
     )
 
     result = df_in.pivot_longer(
-        index="id", names_to=[".value", "group"], names_pattern="(.)(.)",
+        index="id",
+        names_to=[".value", "group"],
+        names_pattern="(.)(.)",
     )
 
     assert_frame_equal(result, df_out)
diff --git a/tests/functions/test_pivot_wider.py b/tests/functions/test_pivot_wider.py
--- a/tests/functions/test_pivot_wider.py
+++ b/tests/functions/test_pivot_wider.py
@@ -246,7 +246,9 @@ def test_names_sort_wrong_type(df_checks_output):
     """Raise TypeError if the wrong type is provided for `names_sort`."""
     with pytest.raises(TypeError):
         df_checks_output.pivot_wider(
-            index="name", names_from=["estimate", "variable"], names_sort=2,
+            index="name",
+            names_from=["estimate", "variable"],
+            names_sort=2,
         )
 
 
@@ -359,7 +361,9 @@ def test_pivot_long_wide_long():
     result = df_in.pivot_wider(index=["a", "b"], names_from="name")
 
     result = result.pivot_longer(
-        index=["a", "b"], names_to=("name", ".value"), names_sep="_",
+        index=["a", "b"],
+        names_to=("name", ".value"),
+        names_sep="_",
     )
     assert_frame_equal(result, df_in)
 
@@ -447,7 +451,9 @@ def test_flatten_levels_false():
     )
 
     assert_frame_equal(
-        result, expected_output, check_dtype=False,
+        result,
+        expected_output,
+        check_dtype=False,
     )
 
 
diff --git a/tests/functions/test_process_text.py b/tests/functions/test_process_text.py
--- a/tests/functions/test_process_text.py
+++ b/tests/functions/test_process_text.py
@@ -126,7 +126,9 @@ def test_str_cat(no_nulls_df):
     """Test outcome for Pandas ``.str.cat()`` method."""
 
     result = no_nulls_df.process_text(
-        column_name="text", string_function="cat", others=["A", "B", "C", "D"],
+        column_name="text",
+        string_function="cat",
+        others=["A", "B", "C", "D"],
     )
 
     expected = no_nulls_df.assign(
@@ -143,7 +145,8 @@ def test_str_cat_result_is_a_string(no_nulls_df):
     """
 
     result = no_nulls_df.process_text(
-        column_name="text", string_function="cat",
+        column_name="text",
+        string_function="cat",
     )
 
     expected = no_nulls_df.assign(text=no_nulls_df["text"].str.cat())
diff --git a/tests/functions/test_update_where.py b/tests/functions/test_update_where.py
--- a/tests/functions/test_update_where.py
+++ b/tests/functions/test_update_where.py
@@ -45,5 +45,7 @@ def test_not_boolean_conditions(df):
     """Raise Error if `conditions` is not a boolean type."""
     with pytest.raises(ValueError):
         df.update_where(
-            conditions=(df.a + 5), target_column_name="c", target_val=10,
+            conditions=(df.a + 5),
+            target_column_name="c",
+            target_val=10,
         )