From 1b8360ed46a8edb36388fbad0036ad5b4deca9be Mon Sep 17 00:00:00 2001 From: aeturrell Date: Mon, 13 Jan 2025 10:36:35 +0000 Subject: [PATCH] pydoclint passing --- .pre-commit-config.yaml | 5 +++++ pyproject.toml | 5 +++++ src/skimpy/__init__.py | 25 ++++++++++++++++++------- src/skimpy/__main__.py | 4 ++-- uv.lock | 27 ++++++++++++++++++++++++++- 5 files changed, 56 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79c15a0c..67aacc05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,3 +54,8 @@ repos: entry: nbstripout language: python types: [jupyter] + - repo: https://github.com/jsh9/pydoclint + rev: 0.6.0 + hooks: + - id: pydoclint + args: [--style=google, --config=pyproject.toml, src/] diff --git a/pyproject.toml b/pyproject.toml index 698d1848..19df1ec0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ dependencies = [ "rich>=13.9.4", "typeguard>=4.4.1", "pyarrow>=17.0.0", + "pydoclint>=0.6.0", ] [dependency-groups] @@ -55,3 +56,7 @@ show_error_codes = true show_error_context = true ignore_missing_imports = true disallow_untyped_calls = false + +[tool.pydoclint] +style = 'google' +exclude = ["noxfile.py", "tests/", "docs/"] diff --git a/src/skimpy/__init__.py b/src/skimpy/__init__.py index 00ee9964..db5d619e 100644 --- a/src/skimpy/__init__.py +++ b/src/skimpy/__init__.py @@ -129,11 +129,12 @@ def _infer_datatypes(df: pd.DataFrame) -> pd.DataFrame: @typechecked -def _round_series(s: pd.Series, places=2) -> pd.Series: +def _round_series(s: pd.Series, places: int = 2) -> pd.Series: """Rounds numerical series to places number of significant figures Args: s (pd.Series): Input series + places (int, optional): Number of significant figures to round to. Defaults to 2. Returns: pd.Series: Series with numbers rounded to places s.f. @@ -289,7 +290,7 @@ def _dataframe_to_rich_table( return table -def _find_nearest(array, value): +def _find_nearest(array: np.ndarray, value: float) -> float: """Find the nearest numerical match to value in an array. Args: @@ -297,7 +298,7 @@ def _find_nearest(array, value): value (float): Single value to find an entry in array that is close. Returns: - np.array: The entry in array that is closest to value. + float: The entry in array that is closest to value. """ array = np.asarray(array) idx = (np.abs(array - value)).argmin() @@ -612,10 +613,13 @@ def _delete_unsupported_columns(df: pd.DataFrame) -> pd.DataFrame: supported. Args: - df (pd.DataFrame): _description_ + df (pd.DataFrame): Input dataframe. Returns: - pd.DataFrame: _description_ + pd.DataFrame: Dataframe with unsupported columns removed. + + Raises: + ValueError: If the input dataframe only has unsupported column types. """ df_types = ( pd.DataFrame(df.apply(pd.api.types.infer_dtype, axis=0)) @@ -643,7 +647,7 @@ def _skim_computation( df_in (pd.DataFrame): Input pandas dataframe to create a summary of. Returns: - [rich.table.Table, JSON]: Rich table grid to print to console, JSON of summary stats. + Tuple[rich.table.Table, JSON]: Rich table grid to print to console, JSON of summary stats. """ if hasattr(df_in, "name") and "name" not in df_in.columns: name = str(df_in.name) @@ -767,6 +771,9 @@ def skim( Args: df_in (Union[pd.DataFrame, pl.DataFrame]): Dataframe to skim. + Raises: + NotImplementedError: If the dataframe has a MultiIndex column structure. + Examples -------- Skim a dataframe @@ -846,6 +853,10 @@ def skim_get_figure( df_in (Union[pd.DataFrame, pl.DataFrame]): Dataframe to skim. save_path (Union[os.PathLike, str]): Path to save figure to (include extension). format (str, optional): svg, html, or text. Defaults to "svg". + + Raises: + + ValueError: If the format is not one of svg, html, or text. """ df_out = _convert_to_pandas(df_in) grid, _ = _skim_computation(df_out) @@ -908,7 +919,7 @@ def clean_columns( ValueError: If case is not valid. Returns: - (Union[pd.DataFrame, pl.DataFrame]): Dataframe with cleaned column names. + Union[pd.DataFrame, pl.DataFrame]: Dataframe with cleaned column names. Examples -------- diff --git a/src/skimpy/__main__.py b/src/skimpy/__main__.py index 9c1be3da..98b220de 100644 --- a/src/skimpy/__main__.py +++ b/src/skimpy/__main__.py @@ -9,11 +9,11 @@ @click.command() @click.version_option() @click.argument("input") -def main(input) -> None: +def main(input: str) -> None: """The skimpy command line interface. Usage refers only to command line. Args: - input ([csv]): A csv file to produce summary statistics on + input (str): String of path of csv file to produce summary statistics on """ df = pd.read_csv(input, parse_dates=True) df = df.infer_objects() diff --git a/uv.lock b/uv.lock index f85e7529..e4c403f2 100644 --- a/uv.lock +++ b/uv.lock @@ -648,6 +648,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/91/a1/cf2472db20f7ce4a6be1253a81cfdf85ad9c7885ffbed7047fb72c24cf87/distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87", size = 468973 }, ] +[[package]] +name = "docstring-parser-fork" +version = "0.0.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c6/72/61f7243ad62e14d527f93304cd4f333e681295aa3ef9bcc4afc36c07001a/docstring_parser_fork-0.0.12.tar.gz", hash = "sha256:b44c5e0be64ae80f395385f01497d381bd094a57221fd9ff020987d06857b2a0", size = 31608 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/50/0d/eed05d4b1065f11f8bef2f57440759d4dacc73c22780764948bfa4aaa304/docstring_parser_fork-0.0.12-py3-none-any.whl", hash = "sha256:55d7cbbc8b367655efd64372b9a0b33a49bae930a8ddd5cdc4c6112312e28a87", size = 42185 }, +] + [[package]] name = "exceptiongroup" version = "1.2.2" @@ -2222,6 +2231,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/fd/ab/718d9a1c41bb8d3e0e04d15b68b8afc135f8fcf552705b62f226225065c7/pydantic_core-2.27.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:62ba45e21cf6571d7f716d903b5b7b6d2617e2d5d67c0923dc47b9d41369f840", size = 2002035 }, ] +[[package]] +name = "pydoclint" +version = "0.6.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "docstring-parser-fork" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/57/08/ef4e3c77279d3e849aaa5c340fbd8f3df4faddd0654f3ee057988dad61e3/pydoclint-0.6.0.tar.gz", hash = "sha256:bee5b509f5407c8ae180ff86a6776895084129097a4600b749fd133fd58a1cf4", size = 53067 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9d/79/9daa3087d4cfc9e5dec7911363b8f1f024a66899559d031fc215fe6724ea/pydoclint-0.6.0-py2.py3-none-any.whl", hash = "sha256:f1fb9676efe70c9a0443c7177186a01001a2227c9100272ef72d7da269ae9bbd", size = 47515 }, +] + [[package]] name = "pygments" version = "2.18.0" @@ -2784,7 +2807,7 @@ wheels = [ [[package]] name = "skimpy" -version = "0.0.17" +version = "0.0.18" source = { virtual = "." } dependencies = [ { name = "click" }, @@ -2794,6 +2817,7 @@ dependencies = [ { name = "pandas-stubs" }, { name = "polars" }, { name = "pyarrow" }, + { name = "pydoclint" }, { name = "pygments" }, { name = "rich" }, { name = "typeguard" }, @@ -2828,6 +2852,7 @@ requires-dist = [ { name = "pandas-stubs", specifier = ">=2.2.2.240807" }, { name = "polars", specifier = ">=1.17.1" }, { name = "pyarrow", specifier = ">=17.0.0" }, + { name = "pydoclint", specifier = ">=0.6.0" }, { name = "pygments", specifier = ">=2.18.0" }, { name = "rich", specifier = ">=13.9.4" }, { name = "typeguard", specifier = ">=4.4.1" },