Skip to content

Commit

Permalink
Fix wrong typing that caused thousands of type ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
frederik-sandfort1 committed Aug 21, 2024
1 parent fa27bfd commit 9baf781
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 60 deletions.
8 changes: 4 additions & 4 deletions molpipeline/abstract_pipeline_elements/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
"uuid": self.uuid,
}

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""As the setter function cannot be assessed with super(), this method is implemented for inheritance.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameters to be set.
Returns
Expand Down Expand Up @@ -379,12 +379,12 @@ def parameters(self) -> dict[str, Any]:
return self.get_params()

@parameters.setter
def parameters(self, **parameters: dict[str, Any]) -> None:
def parameters(self, **parameters: Any) -> None:
"""Set the parameters of the object.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Object parameters as a dictionary.
Returns
Expand Down
16 changes: 8 additions & 8 deletions molpipeline/abstract_pipeline_elements/mol2any/mol2bitvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:

return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set object parameters relevant for copying the class.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary of parameter names and values.
Returns
Expand All @@ -160,7 +160,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
raise ValueError(
f"return_as has to be one of {get_args(OutputDatatype)}! (Received: {return_as})"
)
self._return_as = return_as # type: ignore
self._return_as = return_as
super().set_params(**parameter_dict_copy)
return self

Expand Down Expand Up @@ -300,12 +300,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:

return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set object parameters relevant for copying the class.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary of parameter names and values.
Returns
Expand Down Expand Up @@ -398,12 +398,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
parameters.pop("fill_value", None)
return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary of parameter names and values.
Returns
Expand All @@ -417,7 +417,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:

# explicitly check for None, since 0 is a valid value
if radius is not None:
self._radius = radius # type: ignore
self._radius = radius
# explicitly check for None, since False is a valid value
if use_features is not None:
self._use_features = bool(use_features)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["standardizer"] = self._standardizer
return params

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary with parameter names and corresponding values.
Returns
Expand All @@ -123,7 +123,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
parameter_copy = dict(parameters)
standardizer = parameter_copy.pop("standardizer", None)
if standardizer is not None:
self._standardizer = standardizer # type: ignore
self._standardizer = standardizer
super().set_params(**parameter_copy)
return self

Expand Down
6 changes: 3 additions & 3 deletions molpipeline/any2mol/sdf2mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["identifier"] = self.identifier
return params

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters of the object.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary containing all parameters defining the object.
Returns
Expand All @@ -86,7 +86,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
"""
super().set_params(**parameters)
if "identifier" in parameters:
self.identifier = parameters["identifier"] # type: ignore
self.identifier = parameters["identifier"]
return self

def finish(self) -> None:
Expand Down
8 changes: 4 additions & 4 deletions molpipeline/error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["element_ids"] = self.element_ids
return params

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters for this element.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dict of arameters to set.
Returns
Expand Down Expand Up @@ -508,12 +508,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["fill_value"] = self.fill_value
return params

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters for this element.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameter dict.
Returns
Expand Down
6 changes: 3 additions & 3 deletions molpipeline/mol2any/mol2concatinated_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:

return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameters to set.
Returns
Expand All @@ -129,7 +129,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
parameter_copy = dict(parameters)
element_list = parameter_copy.pop("element_list", None)
if element_list is not None:
self._element_list = element_list # type: ignore
self._element_list = element_list
step_params: dict[str, dict[str, Any]] = {}
step_dict = dict(self._element_list)
to_delete_list = []
Expand Down
6 changes: 3 additions & 3 deletions molpipeline/mol2any/mol2morgan_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
parameters["n_bits"] = self._n_bits
return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary of parameter names and values.
Returns
Expand All @@ -120,7 +120,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
parameter_copy = dict(parameters)
n_bits = parameter_copy.pop("n_bits", None)
if n_bits is not None:
self._n_bits = n_bits # type: ignore
self._n_bits = n_bits
super().set_params(**parameter_copy)

return self
Expand Down
6 changes: 3 additions & 3 deletions molpipeline/mol2any/mol2net_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
parent_dict["charge_policy"] = self._charge_method
return parent_dict

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameters to set
Returns
Expand All @@ -161,6 +161,6 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
parameters_shallow_copy = dict(parameters)
charge_policy = parameters_shallow_copy.pop("charge_policy", None)
if charge_policy is not None:
self._charge_method = charge_policy # type: ignore
self._charge_method = charge_policy
super().set_params(**parameters_shallow_copy)
return self
22 changes: 11 additions & 11 deletions molpipeline/mol2any/mol2path_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
parameters["n_bits"] = self._n_bits
return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary of parameter names and values.
Returns
Expand All @@ -168,36 +168,36 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
parameter_copy = dict(parameters)
min_path = parameter_copy.pop("min_path", None)
if min_path is not None:
self._min_path = min_path # type: ignore
self._min_path = min_path
max_path = parameter_copy.pop("max_path", None)
if max_path is not None:
self._max_path = max_path # type: ignore
self._max_path = max_path
use_hs = parameter_copy.pop("use_hs", None)
if use_hs is not None:
self._use_hs = use_hs # type: ignore
self._use_hs = use_hs
branched_paths = parameter_copy.pop("branched_paths", None)
if branched_paths is not None:
self._branched_paths = branched_paths # type: ignore
self._branched_paths = branched_paths
use_bond_order = parameter_copy.pop("use_bond_order", None)
if use_bond_order is not None:
self._use_bond_order = use_bond_order # type: ignore
self._use_bond_order = use_bond_order
count_simulation = parameter_copy.pop("count_simulation", None)
if count_simulation is not None:
self._count_simulation = count_simulation # type: ignore
self._count_simulation = count_simulation
count_bounds = parameter_copy.pop("count_bounds", None)
if count_bounds is not None:
self._count_bounds = count_bounds # type: ignore
self._count_bounds = count_bounds
num_bits_per_feature = parameter_copy.pop("num_bits_per_feature", None)
if num_bits_per_feature is not None:
self._num_bits_per_feature = num_bits_per_feature # type: ignore
self._num_bits_per_feature = num_bits_per_feature
atom_invariants_generator = parameter_copy.pop(
"atom_invariants_generator", None
)
if atom_invariants_generator is not None:
self._atom_invariants_generator = atom_invariants_generator
n_bits = parameter_copy.pop("n_bits", None) # pylint: disable=duplicate-code
if n_bits is not None:
self._n_bits = n_bits # type: ignore
self._n_bits = n_bits
super().set_params(**parameter_copy)
return self

Expand Down
4 changes: 2 additions & 2 deletions molpipeline/mol2any/mol2rdkit_phys_chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
parent_dict["log_exceptions"] = self._log_exceptions
return parent_dict

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameters to set
Returns
Expand Down
6 changes: 3 additions & 3 deletions molpipeline/mol2mol/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["allowed_element_numbers"] = self.allowed_element_numbers
return params

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters of ElementFilter.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameters to set.
Returns
Expand All @@ -103,7 +103,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
"""
parameter_copy = dict(parameters)
if "allowed_element_numbers" in parameter_copy:
self.allowed_element_numbers = parameter_copy.pop("allowed_element_numbers") # type: ignore
self.allowed_element_numbers = parameter_copy.pop("allowed_element_numbers")
super().set_params(**parameter_copy)
return self

Expand Down
8 changes: 4 additions & 4 deletions molpipeline/mol2mol/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
parameters["handle_multi"] = self.handle_multi
return parameters

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set the parameters.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Dictionary containing parameters to be set.
Returns
Expand All @@ -108,9 +108,9 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
if "reaction" in parameters:
self.reaction = parameters["reaction"]
if "additive_list" in parameters:
self.additive_list = parameters["additive_list"] # type: ignore
self.additive_list = parameters["additive_list"]
if "handle_multi" in parameters:
self.handle_multi = parameters["handle_multi"] # type: ignore
self.handle_multi = parameters["handle_multi"]
return self

@property
Expand Down
6 changes: 3 additions & 3 deletions molpipeline/mol2mol/standardization.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,12 @@ def get_params(self, deep: bool = True) -> dict[str, Any]:
params["solvent_smiles_list"] = self.solvent_smiles_list
return params

def set_params(self, **parameters: dict[str, Any]) -> Self:
def set_params(self, **parameters: Any) -> Self:
"""Set parameters of pipeline element.
Parameters
----------
parameters: dict[str, Any]
parameters: Any
Parameters to set.
Returns
Expand All @@ -416,7 +416,7 @@ def set_params(self, **parameters: dict[str, Any]) -> Self:
param_copy = dict(parameters)
solvent_smiles_list = param_copy.pop("solvent_smiles_list", None)
if solvent_smiles_list is not None:
self.solvent_smiles_list = solvent_smiles_list # type: ignore
self.solvent_smiles_list = solvent_smiles_list
super().set_params(**param_copy)
return self

Expand Down
Loading

0 comments on commit 9baf781

Please sign in to comment.