Skip to content

[INF] Update code_check github actions black version #848

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

Merged
merged 4 commits into from
Jul 19, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/setup-python@v2

- name: Install black
run: python -m pip install black==19.10b0
run: python -m pip install black==21.7b0

- name: Run black
run: black --config pyproject.toml --check .
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]
- [INF] Update pre-commit hooks and remove mutable references. Issue #844. @loganthomas
- [INF] Add GitHub Release pointer to auto-release script. Issue #818. @loganthomas
- [INF] Updated black version in github actions code-checks to match pre-commit hooks. @nvamsikrishna05

## [v0.21.0] - 2021-07-16

Expand Down
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
- python>=3.6, <3.9
- biopython
- black=19.10b0
- black=21.7b0
- bumpversion
- cairo
- conda
Expand Down
7 changes: 5 additions & 2 deletions janitor/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 11 additions & 3 deletions janitor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/functions/test_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/test_convert_excel_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions tests/functions/test_encode_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand Down
29 changes: 24 additions & 5 deletions tests/functions/test_pivot_longer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions tests/functions/test_pivot_wider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -447,7 +451,9 @@ def test_flatten_levels_false():
)

assert_frame_equal(
result, expected_output, check_dtype=False,
result,
expected_output,
check_dtype=False,
)


Expand Down
7 changes: 5 additions & 2 deletions tests/functions/test_process_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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())
Expand Down
4 changes: 3 additions & 1 deletion tests/functions/test_update_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)