diff --git a/.pylintrc b/.pylintrc index 00c2fd1af..dbf8602e3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -71,6 +71,7 @@ disable=fixme, # disabled as TODOs would show up as warnings no-else-return, # relax "elif" after a clause with a return docstring-first-line-empty, # relax docstring style import-outside-toplevel, + unknown-option-value, [REPORTS] diff --git a/qiskit_optimization/algorithms/admm_optimizer.py b/qiskit_optimization/algorithms/admm_optimizer.py index e837ee278..0def1c9bf 100644 --- a/qiskit_optimization/algorithms/admm_optimizer.py +++ b/qiskit_optimization/algorithms/admm_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2020, 2023. +# (C) Copyright IBM 2020, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -42,7 +42,7 @@ class ADMMParameters: """Defines a set of parameters for ADMM optimizer.""" - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, rho_initial: float = 10000, factor_c: float = 100000, @@ -175,7 +175,7 @@ def __init__(self, op: QuadraticProgram, rho_initial: float) -> None: class ADMMOptimizationResult(OptimizationResult): """ADMMOptimization Result.""" - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: np.ndarray, fval: float, diff --git a/qiskit_optimization/algorithms/cobyla_optimizer.py b/qiskit_optimization/algorithms/cobyla_optimizer.py index 8ed291c1e..553014bb7 100644 --- a/qiskit_optimization/algorithms/cobyla_optimizer.py +++ b/qiskit_optimization/algorithms/cobyla_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2020, 2023. +# (C) Copyright IBM 2020, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -43,7 +43,7 @@ class CobylaOptimizer(MultiStartOptimizer): >>> result = optimizer.solve(problem) """ - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, rhobeg: float = 1.0, rhoend: float = 1e-4, diff --git a/qiskit_optimization/algorithms/goemans_williamson_optimizer.py b/qiskit_optimization/algorithms/goemans_williamson_optimizer.py index 989744ceb..bf015944e 100644 --- a/qiskit_optimization/algorithms/goemans_williamson_optimizer.py +++ b/qiskit_optimization/algorithms/goemans_williamson_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2021, 2023. +# (C) Copyright IBM 2021, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -39,7 +39,7 @@ class GoemansWilliamsonOptimizationResult(OptimizationResult): values of just one solution. Explore ``samples`` for all possible solutions. """ - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: Optional[Union[List[float], np.ndarray]], fval: float, diff --git a/qiskit_optimization/algorithms/grover_optimizer.py b/qiskit_optimization/algorithms/grover_optimizer.py index 469ebce18..548ef5da9 100644 --- a/qiskit_optimization/algorithms/grover_optimizer.py +++ b/qiskit_optimization/algorithms/grover_optimizer.py @@ -41,7 +41,7 @@ class GroverOptimizer(OptimizationAlgorithm): """Uses Grover Adaptive Search (GAS) to find the minimum of a QUBO function.""" - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, num_value_qubits: int, num_iterations: int = 3, @@ -325,7 +325,7 @@ def _bin_to_int(v: str, num_value_bits: int) -> int: class GroverOptimizationResult(OptimizationResult): """A result object for Grover Optimization methods.""" - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray], fval: float, diff --git a/qiskit_optimization/algorithms/minimum_eigen_optimizer.py b/qiskit_optimization/algorithms/minimum_eigen_optimizer.py index fc3da66d2..fc0b24262 100644 --- a/qiskit_optimization/algorithms/minimum_eigen_optimizer.py +++ b/qiskit_optimization/algorithms/minimum_eigen_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2020, 2023. +# (C) Copyright IBM 2020, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -39,7 +39,7 @@ class MinimumEigenOptimizationResult(OptimizationResult): """Minimum Eigen Optimizer Result.""" - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: Optional[Union[List[float], np.ndarray]], fval: Optional[float], diff --git a/qiskit_optimization/algorithms/optimization_algorithm.py b/qiskit_optimization/algorithms/optimization_algorithm.py index 0b5b6ef0c..fa21bbc93 100644 --- a/qiskit_optimization/algorithms/optimization_algorithm.py +++ b/qiskit_optimization/algorithms/optimization_algorithm.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2020, 2023. +# (C) Copyright IBM 2020, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -97,7 +97,7 @@ class OptimizationResult: should maintain the order when generating a new ``OptimizationResult`` object. """ - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray] | None, fval: float | None, diff --git a/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py b/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py index 1e99fcb60..add88c0a3 100644 --- a/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py +++ b/qiskit_optimization/algorithms/recursive_minimum_eigen_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2020, 2023. +# (C) Copyright IBM 2020, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -52,7 +52,7 @@ class IntermediateResult(Enum): class RecursiveMinimumEigenOptimizationResult(OptimizationResult): """Recursive Eigen Optimizer Result.""" - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray], fval: float, @@ -137,7 +137,7 @@ class RecursiveMinimumEigenOptimizer(OptimizationAlgorithm): from Symmetry Protection. `arXiv:1910.08980 `_ """ - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, optimizer: OptimizationAlgorithm, min_num_vars: int = 1, diff --git a/qiskit_optimization/algorithms/slsqp_optimizer.py b/qiskit_optimization/algorithms/slsqp_optimizer.py index 2f4ccc84e..47ebb1266 100644 --- a/qiskit_optimization/algorithms/slsqp_optimizer.py +++ b/qiskit_optimization/algorithms/slsqp_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2020, 2023. +# (C) Copyright IBM 2020, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -30,7 +30,7 @@ class SlsqpOptimizationResult(OptimizationResult): SLSQP optimization result, defines additional properties that may be returned by the optimizer. """ - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, x: Union[List[float], np.ndarray], fval: float, @@ -104,7 +104,7 @@ class SlsqpOptimizer(MultiStartOptimizer): """ # pylint: disable=redefined-builtin - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, iter: int = 100, acc: float = 1.0e-6, diff --git a/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py b/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py index 7acd04e09..b57cc7101 100644 --- a/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py +++ b/qiskit_optimization/algorithms/warm_start_qaoa_optimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2021, 2023. +# (C) Copyright IBM 2021, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -198,7 +198,7 @@ class WarmStartQAOAOptimizer(MinimumEigenOptimizer): """ - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, pre_solver: OptimizationAlgorithm, relax_for_pre_solver: bool, diff --git a/qiskit_optimization/applications/max_cut.py b/qiskit_optimization/applications/max_cut.py index 9d9bc5371..a38ce3f31 100644 --- a/qiskit_optimization/applications/max_cut.py +++ b/qiskit_optimization/applications/max_cut.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2018, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -114,10 +114,10 @@ def parse_gset_format(filename: str) -> np.ndarray: w = np.zeros((n, n)) header = False else: - s__, t__, _ = v + s__, t__, w__ = v s__ -= 1 # adjust 1-index t__ -= 1 # ditto - w[s__, t__] = t__ + w[s__, t__] = w__ count += 1 assert m == count w += w.T diff --git a/qiskit_optimization/applications/vehicle_routing.py b/qiskit_optimization/applications/vehicle_routing.py index d22727f5e..86d7b87a2 100644 --- a/qiskit_optimization/applications/vehicle_routing.py +++ b/qiskit_optimization/applications/vehicle_routing.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2018, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -217,7 +217,7 @@ def depot(self, depot: int) -> None: @staticmethod # pylint: disable=undefined-variable - def create_random_instance( + def create_random_instance( # pylint: disable=too-many-positional-arguments n: int, low: int = 0, high: int = 100, diff --git a/qiskit_optimization/problems/linear_constraint.py b/qiskit_optimization/problems/linear_constraint.py index fe07a4758..e144289f9 100644 --- a/qiskit_optimization/problems/linear_constraint.py +++ b/qiskit_optimization/problems/linear_constraint.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2019, 2023. +# (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -27,7 +27,7 @@ class LinearConstraint(Constraint): # Note: added, duplicating in effect that in Constraint, to avoid issues with Sphinx Sense = ConstraintSense - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, name: str, diff --git a/qiskit_optimization/problems/quadratic_constraint.py b/qiskit_optimization/problems/quadratic_constraint.py index 17f768f8b..ee044f36e 100644 --- a/qiskit_optimization/problems/quadratic_constraint.py +++ b/qiskit_optimization/problems/quadratic_constraint.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2019, 2023. +# (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -28,7 +28,7 @@ class QuadraticConstraint(Constraint): # Note: added, duplicating in effect that in Constraint, to avoid issues with Sphinx Sense = ConstraintSense - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, name: str, diff --git a/qiskit_optimization/problems/quadratic_objective.py b/qiskit_optimization/problems/quadratic_objective.py index b81444a5c..385735df9 100644 --- a/qiskit_optimization/problems/quadratic_objective.py +++ b/qiskit_optimization/problems/quadratic_objective.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2019, 2023. +# (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -38,7 +38,7 @@ class QuadraticObjective(QuadraticProgramElement): Sense = ObjSense - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, constant: float = 0.0, diff --git a/qiskit_optimization/problems/quadratic_program.py b/qiskit_optimization/problems/quadratic_program.py index bcbfc5d10..3ab177c27 100644 --- a/qiskit_optimization/problems/quadratic_program.py +++ b/qiskit_optimization/problems/quadratic_program.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2019, 2023. +# (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -185,7 +185,7 @@ def _add_variable( key_format = "" return self._add_variables(1, lowerbound, upperbound, vartype, name, key_format)[1][0] - def _add_variables( + def _add_variables( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int], @@ -239,7 +239,7 @@ def _find_name(name, key_format, k): variables.append(variable) return names, variables - def _var_dict( + def _var_dict( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int], @@ -277,7 +277,7 @@ def _var_dict( zip(*self._add_variables(keys, lowerbound, upperbound, vartype, name, key_format)) ) - def _var_list( + def _var_list( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int], @@ -333,7 +333,7 @@ def continuous_var( """ return self._add_variable(lowerbound, upperbound, Variable.Type.CONTINUOUS, name) - def continuous_var_dict( + def continuous_var_dict( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -367,7 +367,7 @@ def continuous_var_dict( keys, lowerbound, upperbound, Variable.Type.CONTINUOUS, name, key_format ) - def continuous_var_list( + def continuous_var_list( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -494,7 +494,7 @@ def integer_var( """ return self._add_variable(lowerbound, upperbound, Variable.Type.INTEGER, name) - def integer_var_dict( + def integer_var_dict( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -526,7 +526,7 @@ def integer_var_dict( """ return self._var_dict(keys, lowerbound, upperbound, Variable.Type.INTEGER, name, key_format) - def integer_var_list( + def integer_var_list( # pylint: disable=too-many-positional-arguments self, keys: Union[int, Sequence], lowerbound: Union[float, int] = 0, @@ -717,7 +717,7 @@ def quadratic_constraints_index(self) -> Dict[str, int]: """ return self._quadratic_constraints_index - def quadratic_constraint( + def quadratic_constraint( # pylint: disable=too-many-positional-arguments self, linear: Union[ndarray, spmatrix, List[float], Dict[Union[int, str], float]] = None, quadratic: Union[ diff --git a/qiskit_optimization/problems/variable.py b/qiskit_optimization/problems/variable.py index 37f9ec3c0..06d8e0484 100644 --- a/qiskit_optimization/problems/variable.py +++ b/qiskit_optimization/problems/variable.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2019, 2023. +# (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -33,7 +33,7 @@ class Variable(QuadraticProgramElement): Type = VarType - def __init__( + def __init__( # pylint: disable=too-many-positional-arguments self, quadratic_program: Any, name: str, diff --git a/qiskit_optimization/translators/prettyprint.py b/qiskit_optimization/translators/prettyprint.py index 7c002e851..2b4f97b67 100644 --- a/qiskit_optimization/translators/prettyprint.py +++ b/qiskit_optimization/translators/prettyprint.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2022, 2023. +# (C) Copyright IBM 2022, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -117,7 +117,7 @@ def _concatenate_terms(terms: List[str], wrap: int, indent: int) -> str: return buf -def expr2str( +def expr2str( # pylint: disable=too-many-positional-arguments constant: float = 0.0, linear: Optional[LinearExpression] = None, quadratic: Optional[QuadraticExpression] = None,