Skip to content

Commit

Permalink
Remove useless pylint suppressions (Qiskit#9697)
Browse files Browse the repository at this point in the history
* Switch to pyproject.toml no config changes

* Remove trivial differences from default

* Fall back to a few additional defaults

* Remove useless pylint suppressions

* Reblacken

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and king-p3nguin committed May 22, 2023
1 parent cd529d0 commit e1b1d06
Show file tree
Hide file tree
Showing 93 changed files with 58 additions and 138 deletions.
2 changes: 1 addition & 1 deletion qiskit/algorithms/amplitude_estimators/ae.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(
self.quantum_instance = quantum_instance

# get parameters
self._m = num_eval_qubits # pylint: disable=invalid-name
self._m = num_eval_qubits
self._M = 2**num_eval_qubits # pylint: disable=invalid-name

self._iqft = iqft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def rescale(self, scaling_factor: float) -> "EstimationProblem":

# add the scaling qubit to the good state qualifier
def is_good_state(bitstr):
# pylint: disable=not-callable
return self.is_good_state(bitstr[1:]) and bitstr[0] == "1"

# rescaled estimation problem
Expand Down
3 changes: 0 additions & 3 deletions qiskit/algorithms/eigen_solvers/numpy_eigen_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
logger = logging.getLogger(__name__)


# pylint: disable=invalid-name


class NumPyEigensolver(Eigensolver):
r"""
Pending deprecation: NumPy Eigensolver algorithm.
Expand Down
1 change: 0 additions & 1 deletion qiskit/algorithms/eigensolvers/numpy_eigensolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from ..list_or_dict import ListOrDict

logger = logging.getLogger(__name__)
# pylint: disable=invalid-name

FilterType = Callable[[Union[List, np.ndarray], float, Optional[ListOrDict[float]]], bool]

Expand Down
4 changes: 1 addition & 3 deletions qiskit/algorithms/eigensolvers/vqd.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ def compute_eigenvalues(

# TODO: add gradient support after FidelityGradients are implemented
if callable(self.optimizer):
opt_result = self.optimizer( # pylint: disable=not-callable
fun=energy_evaluation, x0=initial_point, bounds=bounds
)
opt_result = self.optimizer(fun=energy_evaluation, x0=initial_point, bounds=bounds)
else:
# we always want to submit as many estimations per job as possible for minimal
# overhead on the hardware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from ..exceptions import AlgorithmError

if sys.version_info >= (3, 8):
# pylint: disable=no-name-in-module, ungrouped-imports
from typing import Literal
else:
from typing_extensions import Literal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from ..exceptions import AlgorithmError

if sys.version_info >= (3, 8):
# pylint: disable=no-name-in-module, ungrouped-imports
# pylint: disable=ungrouped-imports
from typing import Literal
else:
from typing_extensions import Literal
Expand Down
2 changes: 0 additions & 2 deletions qiskit/algorithms/gradients/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=invalid-name

"""
Utility functions for gradients
"""
Expand Down
1 change: 0 additions & 1 deletion qiskit/algorithms/minimum_eigensolvers/sampling_vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def compute_minimum_eigenvalue(
start_time = time()

if callable(self.optimizer):
# pylint: disable=not-callable
optimizer_result = self.optimizer(fun=evaluate_energy, x0=initial_point, bounds=bounds)
else:
# we always want to submit as many estimations per job as possible for minimal
Expand Down
1 change: 0 additions & 1 deletion qiskit/algorithms/optimizers/adam_amsgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def load_params(self, load_dir: str) -> None:
},
since="0.19.0",
)
# pylint: disable=arguments-differ
def minimize(
self,
fun: Callable[[POINT], float],
Expand Down
4 changes: 2 additions & 2 deletions qiskit/algorithms/optimizers/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from qiskit.algorithms.algorithm_result import AlgorithmResult

if sys.version_info >= (3, 8):
# pylint: disable=no-name-in-module, ungrouped-imports
# pylint: disable=ungrouped-imports
from typing import Protocol
else:
from typing_extensions import Protocol
Expand All @@ -41,7 +41,7 @@ class OptimizerResult(AlgorithmResult):

def __init__(self) -> None:
super().__init__()
self._x = None # pylint: disable=invalid-name
self._x = None
self._fun = None
self._jac = None
self._nfev = None
Expand Down
1 change: 0 additions & 1 deletion qiskit/algorithms/optimizers/scipy_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def __init__(
kwargs: additional kwargs for scipy.optimize.minimize.
max_evals_grouped: Max number of default gradient evaluations performed simultaneously.
"""
# pylint: disable=super-init-not-called
self._method = method.lower() if isinstance(method, str) else method
# Set support level
if self._method in self._bounds_support_methods:
Expand Down
2 changes: 1 addition & 1 deletion qiskit/algorithms/optimizers/steppable_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class OptimizerState:
"""

x: POINT # pylint: disable=invalid-name
x: POINT
"""Current optimization parameters."""
fun: Optional[Callable[[POINT], float]]
"""Function being optimized."""
Expand Down
1 change: 0 additions & 1 deletion qiskit/algorithms/phase_estimators/phase_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def estimate_from_pe_circuit(
self._num_evaluation_qubits, circuit_result=circuit_result, phases=phases
)

# pylint: disable=missing-param-doc
def estimate(
self,
unitary: QuantumCircuit,
Expand Down
1 change: 0 additions & 1 deletion qiskit/assembler/assemble_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=unused-import

"""Assemble function for converting a list of circuits into a qobj."""
import hashlib
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/classicalfunction/boolean_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def from_dimacs_file(cls, filename: str):
expr_obj._tweedledum_bool_expression.num_inputs()
+ expr_obj._tweedledum_bool_expression.num_outputs()
)
super(BooleanExpression, expr_obj).__init__( # pylint: disable=no-value-for-parameter
super(BooleanExpression, expr_obj).__init__(
name=basename(filename), num_qubits=num_qubits, params=[]
)
return expr_obj
2 changes: 1 addition & 1 deletion qiskit/circuit/controlflow/if_else.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def _unify_circuit_resources(
return _unify_circuit_registers(true_body, false_body)


def _unify_circuit_resources_rebuild( # pylint: disable=invalid-name # (it's too long?!)
def _unify_circuit_resources_rebuild(
true_body: QuantumCircuit, false_body: QuantumCircuit
) -> Tuple[QuantumCircuit, QuantumCircuit]:
"""
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/equivalence.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import copy
from collections import namedtuple

from rustworkx.visualization import graphviz_draw # pylint: disable=no-name-in-module
from rustworkx.visualization import graphviz_draw
import rustworkx as rx

from qiskit.exceptions import InvalidFileError
Expand Down
1 change: 0 additions & 1 deletion qiskit/circuit/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def to_matrix(self) -> np.ndarray:
exception will be raised when this base class method is called.
"""
if hasattr(self, "__array__"):
# pylint: disable=no-member
return self.__array__(dtype=complex)
raise CircuitError(f"to_matrix not defined for this {type(self)}")

Expand Down
2 changes: 0 additions & 2 deletions qiskit/circuit/library/generalized_gates/diagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=no-member


"""Diagonal matrix circuit."""

Expand Down
4 changes: 2 additions & 2 deletions qiskit/compiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
from qiskit.transpiler.target import Target, target_to_backend_properties

if sys.version_info >= (3, 8):
from multiprocessing.shared_memory import SharedMemory # pylint: disable=no-name-in-module
from multiprocessing.managers import SharedMemoryManager # pylint: disable=no-name-in-module
from multiprocessing.shared_memory import SharedMemory
from multiprocessing.managers import SharedMemoryManager
else:
from shared_memory import SharedMemory, SharedMemoryManager

Expand Down
1 change: 0 additions & 1 deletion qiskit/dagcircuit/dagnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=redefined-builtin

"""Objects to represent the information at a node in the DAGCircuit."""

Expand Down
1 change: 0 additions & 1 deletion qiskit/extensions/quantum_initializer/isometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# pylint: disable=unused-variable
# pylint: disable=missing-param-doc
# pylint: disable=missing-type-doc
# pylint: disable=no-member

"""
Generic isometries from m to n qubits.
Expand Down
1 change: 0 additions & 1 deletion qiskit/opflow/converters/circuit_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def quantum_instance(self, quantum_instance: Union[QuantumInstance, Backend]) ->
self._quantum_instance = quantum_instance
self._check_quantum_instance_and_modes_consistent()

# pylint: disable=arguments-differ
def convert(
self,
operator: OperatorBase,
Expand Down
1 change: 0 additions & 1 deletion qiskit/opflow/evolutions/evolved_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def to_matrix_op(self, massive: bool = False) -> Union[ListOp, MatrixOp]:
def log_i(self, massive: bool = False) -> OperatorBase:
return self.primitive * self.coeff

# pylint: disable=arguments-differ
def to_instruction(self, massive: bool = False) -> Instruction:
mat_op = self.to_matrix_op(massive=massive)
if not isinstance(mat_op, MatrixOp):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class CircuitGradient(ConverterBase):
DerivativeBase - uses classical techniques to differentiate operator flow data structures
"""

# pylint: disable=arguments-differ
@abstractmethod
def convert(
self,
Expand Down
2 changes: 1 addition & 1 deletion qiskit/opflow/gradients/circuit_gradients/lin_comb.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class LinComb(CircuitGradient):
"z",
}

# pylint: disable=signature-differs, arguments-differ
# pylint: disable=signature-differs
def __init__(self, aux_meas_op: OperatorBase = Z):
"""
Args:
Expand Down
1 change: 0 additions & 1 deletion qiskit/opflow/gradients/circuit_qfis/lin_comb_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class LinCombFull(CircuitQFI):
See also :class:`~qiskit.opflow.QFI`.
"""

# pylint: disable=signature-differs, arguments-differ
def __init__(
self,
aux_meas_op: OperatorBase = Z,
Expand Down
1 change: 0 additions & 1 deletion qiskit/opflow/gradients/derivative_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class DerivativeBase(ConverterBase):
DerivativeBase - uses classical techniques to differentiate opflow data structures
"""

# pylint: disable=arguments-differ
@abstractmethod
def convert(
self,
Expand Down
7 changes: 3 additions & 4 deletions qiskit/opflow/list_ops/list_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def to_matrix(self, massive: bool = False) -> np.ndarray:
# Note: this can end up, when we have list operators containing other list operators, as a
# ragged array and numpy 1.19 raises a deprecation warning unless this is explicitly
# done as object type now - was implicit before.
mat = self.combo_fn( # pylint: disable=not-callable
mat = self.combo_fn(
np.asarray(
[op.to_matrix(massive=massive) * self.coeff for op in self.oplist], dtype=object
)
Expand All @@ -374,7 +374,6 @@ def to_spmatrix(self) -> Union[spmatrix, List[spmatrix]]:
"""

# Combination function must be able to handle classical values
# pylint: disable=not-callable
return self.combo_fn([op.to_spmatrix() for op in self.oplist]) * self.coeff

def eval(
Expand Down Expand Up @@ -441,7 +440,7 @@ def eval(
"Combo_fn not yet supported for mixed measurement "
"and non-measurement StateFns"
)
result = self.combo_fn(evals) # pylint: disable=not-callable
result = self.combo_fn(evals)
if isinstance(result, list):
multiplied = self.coeff * np.array(result)
return multiplied.tolist()
Expand All @@ -452,7 +451,7 @@ def eval(
elif any(isinstance(op, OperatorBase) for op in evals):
raise TypeError("Cannot handle mixed scalar and Operator eval results.")
else:
result = self.combo_fn(evals) # pylint: disable=not-callable
result = self.combo_fn(evals)
if isinstance(result, list):
multiplied = self.coeff * np.array(result)
return multiplied.tolist()
Expand Down
2 changes: 0 additions & 2 deletions qiskit/opflow/operator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ def equals(self, other: "OperatorBase") -> bool:

# Scalar Multiplication

# pylint: disable=arguments-differ
@abstractmethod
def mul(self, scalar: Union[complex, ParameterExpression]) -> "OperatorBase":
r"""
Expand Down Expand Up @@ -446,7 +445,6 @@ def copy(self) -> "OperatorBase":

# Composition

# pylint: disable=arguments-differ
@abstractmethod
def compose(
self, other: "OperatorBase", permutation: Optional[List[int]] = None, front: bool = False
Expand Down
1 change: 0 additions & 1 deletion qiskit/opflow/primitive_ops/pauli_sum_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def __len__(self) -> int:
"""
return len(self.primitive)

# pylint: disable=arguments-differ
def reduce(self, atol: Optional[float] = None, rtol: Optional[float] = None) -> "PauliSumOp":
"""Simplify the primitive ``SparsePauliOp``.
Expand Down
2 changes: 1 addition & 1 deletion qiskit/opflow/state_fns/circuit_state_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def tensor(self, other: OperatorBase) -> Union["CircuitStateFn", TensoredOp]:
c_op = c_op_self.tensor(c_op_other)
if isinstance(c_op, CircuitOp):
return CircuitStateFn(
primitive=c_op.primitive, # pylint: disable=no-member
primitive=c_op.primitive,
coeff=c_op.coeff,
is_measurement=self.is_measurement,
)
Expand Down
3 changes: 1 addition & 2 deletions qiskit/primitives/backend_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class BackendEstimator(BaseEstimator):
precludes doing any provider- or backend-specific optimizations.
"""

# pylint: disable=missing-raises-doc
def __init__(
self,
backend: BackendV1 | BackendV2,
Expand Down Expand Up @@ -142,7 +141,7 @@ def __init__(
def __new__( # pylint: disable=signature-differs
cls,
backend: BackendV1 | BackendV2, # pylint: disable=unused-argument
**kwargs, # pylint: disable=unused-argument
**kwargs,
):
self = super().__new__(cls)
return self
Expand Down
2 changes: 1 addition & 1 deletion qiskit/primitives/backend_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
def __new__( # pylint: disable=signature-differs
cls,
backend: BackendV1 | BackendV2, # pylint: disable=unused-argument
**kwargs, # pylint: disable=unused-argument
**kwargs,
):
self = super().__new__(cls)
return self
Expand Down
1 change: 0 additions & 1 deletion qiskit/providers/basicaer/basicaerjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def submit(self):
return

def result(self, timeout=None):
# pylint: disable=arguments-differ
"""Get job result .
Returns:
Expand Down
1 change: 0 additions & 1 deletion qiskit/providers/basicaer/basicaerprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def get_backend(self, name=None, **kwargs):
return super().get_backend(name=name, **kwargs)

def backends(self, name=None, filters=None, **kwargs):
# pylint: disable=arguments-differ
backends = self._backends.values()

# Special handling of the `name` parameter, to support alias resolution
Expand Down
2 changes: 0 additions & 2 deletions qiskit/providers/basicaer/qasm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=arguments-differ

"""Contains a (slow) Python simulator.
It simulates a qasm quantum circuit (an experiment) that has been compiled
Expand Down
2 changes: 0 additions & 2 deletions qiskit/providers/basicaer/unitary_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=arguments-differ

"""Contains a Python simulator that returns the unitary of the circuit.
It simulates a unitary of a quantum circuit that has been compiled to run on
Expand Down
1 change: 0 additions & 1 deletion qiskit/providers/fake_provider/fake_backend_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=no-name-in-module

"""Mock BackendV2 object without run implemented for testing backwards compat"""

Expand Down
Loading

0 comments on commit e1b1d06

Please sign in to comment.