Skip to content

Commit

Permalink
Fix linting errors (#114)
Browse files Browse the repository at this point in the history
* adapt _fit to match sklearn >= 1.6

* check type

* change type casting

* reduce used vars

* overhaul typing

* use new variable

* dont override variable type and ignore too many return statements

* ignore types

* generalize type

* Add typing

* ignore error

* do not reuse var

* decode file

* ignore that Hash functions cannot be found

* false positive

* type cast

* ignore rdkit typing

* add type

* improve docstring

* remove invalid dtype param
  • Loading branch information
c-w-feldmann authored Jan 7, 2025
1 parent 2f9baee commit 335b2e3
Show file tree
Hide file tree
Showing 22 changed files with 139 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ def __init__(
self.counted = counted

@abc.abstractmethod
def _get_fp_generator(self) -> rdFingerprintGenerator.FingeprintGenerator64:
def _get_fp_generator(self) -> rdFingerprintGenerator.FingerprintGenerator64:
"""Get fingerprint generator.
Returns
-------
rdFingerprintGenerator.FingeprintGenerator64
rdFingerprintGenerator.FingerprintGenerator64
Fingerprint generator.
"""

Expand Down
12 changes: 7 additions & 5 deletions molpipeline/abstract_pipeline_elements/mol2mol/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["filter_elements"] = self.filter_elements
return params

def pretransform_single(self, value: RDKitMol) -> OptionalMol:
def pretransform_single( # pylint: disable=too-many-return-statements
self, value: RDKitMol
) -> OptionalMol:
"""Invalidate or validate molecule based on specified filter.
There are four possible scenarios:
Expand All @@ -195,7 +197,7 @@ def pretransform_single(self, value: RDKitMol) -> OptionalMol:
# For "any" mode we can return early if a match is found
if self.mode == "any":
if not self.keep_matches:
value = InvalidInstance(
return InvalidInstance(
self.uuid,
f"Molecule contains forbidden filter element {filter_element}.",
self.name,
Expand All @@ -205,7 +207,7 @@ def pretransform_single(self, value: RDKitMol) -> OptionalMol:
# For "all" mode we can return early if a match is not found
if self.mode == "all":
if self.keep_matches:
value = InvalidInstance(
return InvalidInstance(
self.uuid,
f"Molecule does not contain required filter element {filter_element}.",
self.name,
Expand All @@ -216,7 +218,7 @@ def pretransform_single(self, value: RDKitMol) -> OptionalMol:
# If mode is "any", finishing the loop means no match was found
if self.mode == "any":
if self.keep_matches:
value = InvalidInstance(
return InvalidInstance(
self.uuid,
"Molecule does not match any of the required filter elements.",
self.name,
Expand All @@ -226,7 +228,7 @@ def pretransform_single(self, value: RDKitMol) -> OptionalMol:

if self.mode == "all":
if not self.keep_matches:
value = InvalidInstance(
return InvalidInstance(
self.uuid,
"Molecule matches all forbidden filter elements.",
self.name,
Expand Down
2 changes: 1 addition & 1 deletion molpipeline/any2mol/sdf2mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ def pretransform_single(self, value: str) -> OptionalMol:
self.name,
)
if self.identifier == "smiles":
mol.SetProp("identifier", self.mol_counter)
mol.SetProp("identifier", str(self.mol_counter))
self.mol_counter += 1
return mol
Loading

0 comments on commit 335b2e3

Please sign in to comment.