diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2721929..3d9e72d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: # Check for spelling - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.0 hooks: - id: codespell args: ["-L", "tre"] @@ -46,7 +46,7 @@ repos: # Ruff, the Python auto-correcting linter/formatter written in Rust - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.1 + rev: v0.9.3 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -54,7 +54,7 @@ repos: # Check types with mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v1.14.1 hooks: - id: mypy args: ["--ignore-missing-imports", "--follow-imports", "skip", "--check-untyped-defs"] diff --git a/acro/acro_tables.py b/acro/acro_tables.py index 693cbf3..09cc149 100644 --- a/acro/acro_tables.py +++ b/acro/acro_tables.py @@ -964,13 +964,9 @@ def get_aggfunc(aggfunc: str | None) -> str | Callable | None: func = None if aggfunc is not None: if not isinstance(aggfunc, str): # pragma: no cover - raise ValueError( - f"aggfunc {aggfunc} must be:" f"{', '.join(AGGFUNC.keys())}" - ) + raise ValueError(f"aggfunc {aggfunc} must be:{', '.join(AGGFUNC.keys())}") if aggfunc not in AGGFUNC: # pragma: no cover - raise ValueError( - f"aggfunc {aggfunc} must be: " f"{', '.join(AGGFUNC.keys())}" - ) + raise ValueError(f"aggfunc {aggfunc} must be: {', '.join(AGGFUNC.keys())}") func = AGGFUNC[aggfunc] logger.debug("aggfunc: %s", func) return func @@ -1312,7 +1308,7 @@ def get_queries(masks, aggfunc) -> list[str]: ( f"({index_level_names} == {row_label})" if isinstance(row_label, (int, float)) - else (f"({index_level_names}" f'== "{row_label}")') + else (f'({index_level_names}== "{row_label}")') ) ] ) @@ -1333,7 +1329,7 @@ def get_queries(masks, aggfunc) -> list[str]: ( f"({column_level_names} == {col_label})" if isinstance(col_label, (int, float)) - else (f"({column_level_names}" f'== "{col_label}")') + else (f'({column_level_names}== "{col_label}")') ) ] ) diff --git a/notebooks/test-nursery.py b/notebooks/test-nursery.py index 2bb18fd..82989ea 100644 --- a/notebooks/test-nursery.py +++ b/notebooks/test-nursery.py @@ -122,9 +122,7 @@ # Mean() in this case # Then how Max and Min are not allowed by the code -print( - "\nIllustration of crosstab using an aggregation function " "- mean in this case." -) +print("\nIllustration of crosstab using an aggregation function - mean in this case.") safe_table = acro.crosstab(df.recommend, df.parents, values=df.children, aggfunc="mean") print("\nand this is the researchers output") print(safe_table) diff --git a/test/test_initial.py b/test/test_initial.py index c501eef..b310167 100644 --- a/test/test_initial.py +++ b/test/test_initial.py @@ -620,9 +620,9 @@ def test_surv_func(acro): _ = acro.surv_func(data.futime, data.death, output="table") output = acro.results.get_index(0) correct_summary: str = "fail; threshold: 3864 cells suppressed; " - assert ( - output.summary == correct_summary - ), f"\n{output.summary}\n should be \n{correct_summary}\n" + assert output.summary == correct_summary, ( + f"\n{output.summary}\n should be \n{correct_summary}\n" + ) filename = os.path.normpath("acro_artifacts/kaplan-meier_0.png") _ = acro.surv_func(data.futime, data.death, output="plot") @@ -876,9 +876,9 @@ def test_crosstab_multiple_aggregate_function(data, acro): " p-ratio: 4 cells may need suppressing; " "nk-rule: 2 cells may need suppressing; " ) - assert ( - output.summary == correct_summary - ), f"\n{output.summary}\n should be \n{correct_summary}\n" + assert output.summary == correct_summary, ( + f"\n{output.summary}\n should be \n{correct_summary}\n" + ) print(f"{output.output[0]['mean']['R/G'].sum()}") correctval = 97383496.0 errmsg = f"{output.output[0]['mean']['R/G'].sum()} should be {correctval}" diff --git a/test/test_stata17_interface.py b/test/test_stata17_interface.py index 729b196..2c0c848 100644 --- a/test/test_stata17_interface.py +++ b/test/test_stata17_interface.py @@ -131,9 +131,9 @@ def test_stata_acro_init(): options="", stata_version="17", ) - assert ( - ret == "acro analysis session created\n" - ), f"wrong string for acro init: {ret}\n" + assert ret == "acro analysis session created\n", ( + f"wrong string for acro init: {ret}\n" + ) errmsg = f"wrong type for stata_acro:{type(stata_config.stata_acro)}" assert isinstance(stata_config.stata_acro, ACRO), errmsg @@ -808,9 +808,9 @@ def test_table_stata17_2(data): options="nototals", stata_version="17", ) - assert ( - ret.split() == ret_1.split() == correct.split() - ), f"got\n{ret}\n expected\n{correct}" + assert ret.split() == ret_1.split() == correct.split(), ( + f"got\n{ret}\n expected\n{correct}" + ) def test_table_stata17_3(data): diff --git a/test/test_stata_interface.py b/test/test_stata_interface.py index 2cb80d4..da4a91e 100644 --- a/test/test_stata_interface.py +++ b/test/test_stata_interface.py @@ -217,9 +217,9 @@ def test_stata_acro_init(): options="", stata_version="16", ) - assert ( - ret == "acro analysis session created\n" - ), f"wrong string for acro init: {ret}\n" + assert ret == "acro analysis session created\n", ( + f"wrong string for acro init: {ret}\n" + ) errmsg = f"wrong type for stata_acro:{type(stata_config.stata_acro)}" assert isinstance(stata_config.stata_acro, ACRO), errmsg