Skip to content

Commit

Permalink
infra: satisfy the shiny new ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmjl committed Oct 8, 2023
1 parent 0f356e9 commit 96122f4
Show file tree
Hide file tree
Showing 89 changed files with 221 additions and 268 deletions.
1 change: 0 additions & 1 deletion janitor/engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from .utils import check, import_message


try:
import unyt
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion janitor/finance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import requests

from janitor.errors import JanitorError
from .utils import check, deprecated_alias, is_connected

from .utils import check, deprecated_alias, is_connected

currency_set = {
"AUD",
Expand Down
69 changes: 0 additions & 69 deletions janitor/functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,72 +14,3 @@
6. Try to group related functions together (e.g. see `convert_date.py`)
7. Never import utils.
"""


from .add_columns import add_columns
from .also import also
from .bin_numeric import bin_numeric
from .case_when import case_when
from .change_type import change_type
from .clean_names import clean_names
from .coalesce import coalesce
from .collapse_levels import collapse_levels
from .complete import complete
from .concatenate_columns import concatenate_columns
from .conditional_join import conditional_join
from .convert_date import (
convert_excel_date,
convert_matlab_date,
convert_unix_date,
)
from .count_cumulative_unique import count_cumulative_unique
from .currency_column_to_numeric import currency_column_to_numeric
from .deconcatenate_column import deconcatenate_column
from .drop_constant_columns import drop_constant_columns
from .drop_duplicate_columns import drop_duplicate_columns
from .dropnotnull import dropnotnull
from .encode_categorical import encode_categorical
from .expand_column import expand_column
from .expand_grid import expand_grid
from .factorize_columns import factorize_columns
from .fill import fill_direction, fill_empty
from .filter import filter_date, filter_column_isin, filter_on, filter_string
from .find_replace import find_replace
from .flag_nulls import flag_nulls
from .get_dupes import get_dupes
from .groupby_agg import groupby_agg
from .groupby_topk import groupby_topk
from .impute import impute
from .jitter import jitter
from .join_apply import join_apply
from .label_encode import label_encode
from .limit_column_characters import limit_column_characters
from .min_max_scale import min_max_scale
from .move import move
from .pivot import pivot_longer, pivot_wider
from .process_text import process_text
from .remove_columns import remove_columns
from .remove_empty import remove_empty
from .rename_columns import rename_column, rename_columns
from .reorder_columns import reorder_columns
from .round_to_fraction import round_to_fraction
from .row_to_names import row_to_names
from .select import select_columns, select_rows, select
from .shuffle import shuffle
from .sort_column_value_order import sort_column_value_order
from .sort_naturally import sort_naturally
from .take_first import take_first
from .then import then
from .to_datetime import to_datetime
from .toset import toset
from .transform_columns import transform_column, transform_columns
from .truncate_datetime import truncate_datetime_dataframe
from .update_where import update_where
from .utils import (
patterns,
unionize_dataframe_categories,
DropLabel,
get_index_labels,
col,
get_columns,
)
7 changes: 4 additions & 3 deletions janitor/functions/_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import numpy as np
import pandas as pd
from numba import njit, prange
from pandas.api.types import is_datetime64_dtype, is_extension_array_dtype

from janitor.functions.utils import (
_generic_func_cond_join,
_JoinOperator,
less_than_join_types,
greater_than_join_types,
less_than_join_types,
)
from numba import njit, prange
from pandas.api.types import is_extension_array_dtype, is_datetime64_dtype


def _numba_equi_join(df, right, eqs, ge_gt, le_lt):
Expand Down
7 changes: 4 additions & 3 deletions janitor/functions/add_columns.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Any, List, Tuple, Union

import numpy as np
import pandas as pd
import pandas_flavor as pf

from janitor.utils import check, deprecated_alias, refactored_function
import pandas as pd
from typing import Union, List, Any, Tuple
import numpy as np


@pf.register_dataframe_method
Expand Down
3 changes: 2 additions & 1 deletion janitor/functions/also.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Implementation source for chainable function `also`."""
from typing import Any, Callable
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf


@pf.register_dataframe_method
Expand Down
6 changes: 3 additions & 3 deletions janitor/functions/bin_numeric.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Implementation source for `bin_numeric`."""
from typing import Any, Optional, Union, Sequence
import pandas_flavor as pf
from typing import Any, Optional, Sequence, Union

import pandas as pd
import pandas_flavor as pf

from janitor.utils import check, check_column, deprecated_alias


ScalarSequence = Sequence[float]


Expand Down
8 changes: 5 additions & 3 deletions janitor/functions/case_when.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Implementation source for `case_when`."""
from pandas.core.common import apply_if_callable
import warnings
from typing import Any
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf
from pandas.api.types import is_scalar
import warnings
from pandas.core.common import apply_if_callable

from janitor.utils import check, find_stack_level

warnings.simplefilter("always", DeprecationWarning)
Expand Down
9 changes: 5 additions & 4 deletions janitor/functions/clean_names.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Functions for cleaning columns names."""
from janitor.utils import deprecated_alias
from janitor.functions.utils import get_index_labels, _is_str_or_cat
from pandas.api.types import is_scalar
import unicodedata
from typing import Hashable, Optional, Union

import pandas as pd
import pandas_flavor as pf
from pandas.api.types import is_scalar

from janitor.errors import JanitorError
import unicodedata
from janitor.functions.utils import _is_str_or_cat, get_index_labels
from janitor.utils import deprecated_alias


@pf.register_dataframe_method
Expand Down
3 changes: 2 additions & 1 deletion janitor/functions/coalesce.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Function for performing coalesce."""
from typing import Any, Optional, Union

import pandas as pd
import pandas_flavor as pf

from janitor.utils import check, deprecated_alias
from janitor.functions.utils import get_index_labels
from janitor.utils import check, deprecated_alias


@pf.register_dataframe_method
Expand Down
2 changes: 1 addition & 1 deletion janitor/functions/collapse_levels.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Implementation of the `collapse_levels` function."""
import pandas as pd
import pandas_flavor as pf
from pandas.api.types import is_string_dtype

from janitor.utils import check
from pandas.api.types import is_string_dtype


@pf.register_dataframe_method
Expand Down
12 changes: 6 additions & 6 deletions janitor/functions/complete.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from typing import Optional, Union, List, Tuple, Dict, Any
from pandas.core.common import apply_if_callable
import pandas_flavor as pf
import pandas as pd
import functools
from pandas.api.types import is_list_like, is_scalar
from typing import Any, Dict, List, Optional, Tuple, Union

from janitor.utils import check, check_column
import pandas as pd
import pandas_flavor as pf
from pandas.api.types import is_list_like, is_scalar
from pandas.core.common import apply_if_callable

from janitor.functions.utils import _computations_expand_grid
from janitor.utils import check, check_column


@pf.register_dataframe_method
Expand Down
5 changes: 3 additions & 2 deletions janitor/functions/concatenate_columns.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Hashable, List
import pandas_flavor as pf

import pandas as pd
from janitor.errors import JanitorError
import pandas_flavor as pf

from janitor.errors import JanitorError
from janitor.utils import deprecated_alias


Expand Down
15 changes: 8 additions & 7 deletions janitor/functions/conditional_join.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
from __future__ import annotations

import operator
from typing import Union, Any, Optional, Hashable, Literal
import warnings
from typing import Any, Hashable, Literal, Optional, Union

import numpy as np
import pandas as pd
import pandas_flavor as pf
import warnings
from pandas.core.dtypes.common import (
is_datetime64_dtype,
is_dtype_equal,
is_extension_array_dtype,
is_numeric_dtype,
is_string_dtype,
)

from pandas.core.reshape.merge import _MergeOperation

from janitor.utils import check, check_column, find_stack_level
from janitor.functions.utils import (
_JoinOperator,
_generic_func_cond_join,
_JoinOperator,
_keep_output,
less_than_join_types,
greater_than_join_types,
col,
greater_than_join_types,
less_than_join_types,
)
from janitor.utils import check, check_column, find_stack_level

warnings.simplefilter("always", DeprecationWarning)

Expand Down
5 changes: 3 additions & 2 deletions janitor/functions/convert_date.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from pandas.errors import OutOfBoundsDatetime
import datetime as dt
from typing import Hashable
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf
from pandas.api.types import is_numeric_dtype
from pandas.errors import OutOfBoundsDatetime

from janitor.utils import deprecated_alias

Expand Down
2 changes: 1 addition & 1 deletion janitor/functions/count_cumulative_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Hashable

import numpy as np
import pandas_flavor as pf
import pandas as pd
import pandas_flavor as pf

from janitor.utils import check_column

Expand Down
3 changes: 2 additions & 1 deletion janitor/functions/currency_column_to_numeric.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from functools import partial
from typing import Optional, Union
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf

from janitor.utils import check, check_column, deprecated_alias

Expand Down
5 changes: 3 additions & 2 deletions janitor/functions/deconcatenate_column.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Implementation of deconcatenating columns."""
from typing import Hashable, List, Optional, Tuple, Union
import pandas_flavor as pf

import pandas as pd
from janitor.errors import JanitorError
import pandas_flavor as pf

from janitor.errors import JanitorError
from janitor.utils import deprecated_alias


Expand Down
2 changes: 1 addition & 1 deletion janitor/functions/drop_constant_columns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Implementation of drop_constant_columns."""
import pandas_flavor as pf
import pandas as pd
import pandas_flavor as pf


@pf.register_dataframe_method
Expand Down
3 changes: 2 additions & 1 deletion janitor/functions/drop_duplicate_columns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Implementation for `drop_duplicate_columns`."""
from typing import Hashable
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf


@pf.register_dataframe_method
Expand Down
3 changes: 2 additions & 1 deletion janitor/functions/dropnotnull.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Implementation source for `dropnotnull`."""
from typing import Hashable
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf

from janitor.utils import deprecated_alias

Expand Down
2 changes: 1 addition & 1 deletion janitor/functions/encode_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import pandas_flavor as pf
from pandas.api.types import is_list_like

from janitor.utils import check_column, deprecated_alias, find_stack_level
from janitor.functions.utils import get_index_labels
from janitor.utils import check_column, deprecated_alias, find_stack_level


@pf.register_dataframe_method
Expand Down
6 changes: 3 additions & 3 deletions janitor/functions/expand_grid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Implementation source for `expand_grid`."""
from typing import Dict, Optional, Union
import pandas_flavor as pf
import pandas as pd

from janitor.utils import check
import pandas as pd
import pandas_flavor as pf

from janitor.functions.utils import _computations_expand_grid
from janitor.utils import check


@pf.register_dataframe_method
Expand Down
3 changes: 2 additions & 1 deletion janitor/functions/factorize_columns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Implementation of the `factorize_columns` function"""
from typing import Any, Hashable, Iterable, Union
import pandas_flavor as pf

import pandas as pd
import pandas_flavor as pf

from janitor.functions.utils import _factorize

Expand Down
Loading

0 comments on commit 96122f4

Please sign in to comment.