From 899f74b6160668ce30ac8dc2cdb5e01ccf555fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bouysset?= Date: Mon, 26 Aug 2024 17:35:31 +0100 Subject: [PATCH] fix linting --- prolif/interactions/base.py | 6 ++---- pyproject.toml | 7 +++---- tests/test_ifp.py | 6 +++--- tests/test_interactions.py | 2 +- tests/test_utils.py | 14 +++++++------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/prolif/interactions/base.py b/prolif/interactions/base.py index 00d9736..ecb8486 100644 --- a/prolif/interactions/base.py +++ b/prolif/interactions/base.py @@ -67,11 +67,9 @@ def metadata(self, lig_res, prot_res, lig_indices, prot_indices, **data): "protein": prot_indices, }, "parent_indices": { - "ligand": tuple( - [get_mapindex(lig_res, index) for index in lig_indices], - ), + "ligand": tuple(get_mapindex(lig_res, index) for index in lig_indices), "protein": tuple( - [get_mapindex(prot_res, index) for index in prot_indices], + get_mapindex(prot_res, index) for index in prot_indices ), }, **data, diff --git a/pyproject.toml b/pyproject.toml index 335c438..1d47d62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,9 +105,7 @@ exclude = [ "dist", "site-packages", ] - -[tool.ruff.format] -exclude = ["*.ipynb"] +extend-exclude = ["*.ipynb"] [tool.ruff.lint] select = [ @@ -150,7 +148,8 @@ select = [ ] ignore = [ "PLW1514", "PTH123", "PLR0904", "PLR0911", "PLR0913", "PLR0914", "PLR0915", - "PLR0916", "PLR0917", "PLR2004", "PLR6301", "PD901", "PT018", "FURB103", "COM812", + "PLR0916", "PLR0917", "PLR2004", "PLR6301", "PD901", "PT001", "PT018", "FURB103", + "COM812", # typing incompatible with 3.9 "UP035", "UP006", "UP007", ] diff --git a/tests/test_ifp.py b/tests/test_ifp.py index 150d67f..9daba7f 100644 --- a/tests/test_ifp.py +++ b/tests/test_ifp.py @@ -14,8 +14,8 @@ def ifp(u, ligand_ag, protein_ag) -> IFP: def test_ifp_indexing(ifp: IFP) -> None: lig_id, prot_id = "LIG1.G", "LEU126.A" - metadata1 = ifp[(ResidueId.from_string(lig_id), ResidueId.from_string(prot_id))] - metadata2 = ifp[(lig_id, prot_id)] + metadata1 = ifp[ResidueId.from_string(lig_id), ResidueId.from_string(prot_id)] + metadata2 = ifp[lig_id, prot_id] assert metadata1 is metadata2 @@ -24,7 +24,7 @@ def test_ifp_filtering(ifp: IFP) -> None: assert ifp[lig_id] == ifp assert ( next(iter(ifp[prot_id].values())) - == ifp[(ResidueId.from_string(lig_id), ResidueId.from_string(prot_id))] + == ifp[ResidueId.from_string(lig_id), ResidueId.from_string(prot_id)] ) diff --git a/tests/test_interactions.py b/tests/test_interactions.py index 0b0067c..640cb3a 100644 --- a/tests/test_interactions.py +++ b/tests/test_interactions.py @@ -139,7 +139,7 @@ def detect(self): assert old != new # fix dummy Hydrophobic class being reused in later unrelated tests - class Hydrophobic(prolif.interactions.Hydrophobic): # noqa: F811 + class Hydrophobic(prolif.interactions.Hydrophobic): __doc__ = prolif.interactions.Hydrophobic.__doc__ def test_error_no_detect(self): diff --git a/tests/test_utils.py b/tests/test_utils.py index e465e4c..735edad 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -199,13 +199,13 @@ def test_to_df(ifp): assert df.dtypes.iloc[0].type is np.bool_ assert df.index.name == "Frame" assert ("LIG", "ALA1", "A") in df.columns - assert df[("LIG", "ALA1", "A")][0] is np.bool_(True) + assert df["LIG", "ALA1", "A"][0] is np.bool_(True) assert ("LIG", "ALA1", "B") in df.columns - assert df[("LIG", "ALA1", "B")][0] is np.bool_(False) + assert df["LIG", "ALA1", "B"][0] is np.bool_(False) assert ("LIG", "ALA1", "C") not in df.columns assert ("LIG", "GLU2", "A") not in df.columns assert ("LIG", "ASP3", "B") in df.columns - assert df[("LIG", "ASP3", "B")][0] is np.bool_(False) + assert df["LIG", "ASP3", "B"][0] is np.bool_(False) @pytest.mark.parametrize( @@ -219,9 +219,9 @@ def test_to_df(ifp): def test_to_df_dtype(dtype, ifp): df = to_dataframe(ifp, ["A", "B", "C"], dtype=dtype) assert df.dtypes.iloc[0].type is dtype - assert df[("LIG", "ALA1", "A")][0] == dtype(True) - assert df[("LIG", "ALA1", "B")][0] == dtype(False) - assert df[("LIG", "ASP3", "B")][0] == dtype(False) + assert df["LIG", "ALA1", "A"][0] == dtype(True) + assert df["LIG", "ALA1", "B"][0] == dtype(False) + assert df["LIG", "ASP3", "B"][0] == dtype(False) def test_to_df_drop_empty(ifp): @@ -238,7 +238,7 @@ def test_to_df_no_interaction_in_first_frame(ifp_single): def test_to_df_count(ifp_count): df = to_dataframe(ifp_count, ["A", "B", "C"], count=True) assert df[df > 1].any().any() - value = df[("LIG", "ALA1", "A")][0] + value = df["LIG", "ALA1", "A"][0] assert value.dtype == np.uint8 assert value == 2