Skip to content

Commit

Permalink
Bump pylint to 3.2.2 (#12520)
Browse files Browse the repository at this point in the history
* Bump pylint to 3.2.2

This upgrades pylint to a version compatible with Python 3.8 through
3.12, like Qiskit.  There are a couple of false positives (pylint is
incorrect about its `use-yield-from` in the cases it flags), and has
included a couple of new stylistic opinions that are not necessary to
enforce.

The `possibly-used-before-assignment` lint is quite possibly a good one,
but there are far too many instances in the Qiskit codebase right now to
fix, whereas our current version of pylint is preventing us from running
it with Python 3.12.

* Update requirements-dev.txt

Co-authored-by: Pierre Sassoulas <[email protected]>

* Remove suppressions fixed in pylint 3.2.3

---------

Co-authored-by: Pierre Sassoulas <[email protected]>
Co-authored-by: Matthew Treinish <[email protected]>
  • Loading branch information
3 people authored Jun 6, 2024
1 parent d1c8404 commit 92e78ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ disable = [
"docstring-first-line-empty", # relax docstring style
"import-outside-toplevel", "import-error", # overzealous with our optionals/dynamic packages
"nested-min-max", # this gives false equivalencies if implemented for the current lint version
"consider-using-max-builtin", "consider-using-min-builtin", # unnecessary stylistic opinion
# TODO(#9614): these were added in modern Pylint. Decide if we want to enable them. If so,
# remove from here and fix the issues. Else, move it above this section and add a comment
# with the rationale
Expand All @@ -222,6 +223,7 @@ disable = [
"no-member",
"no-value-for-parameter",
"not-context-manager",
"possibly-used-before-assignment",
"unexpected-keyword-arg",
"unnecessary-dunder-call",
"unnecessary-lambda-assignment",
Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import re
from collections.abc import Iterator, Iterable, Callable
from functools import wraps
from typing import Union, List, Any
from typing import Union, List, Any, TypeVar

from qiskit.circuit import QuantumCircuit
from qiskit.converters import circuit_to_dag, dag_to_circuit
Expand All @@ -31,7 +31,7 @@
from .exceptions import TranspilerError
from .layout import TranspileLayout, Layout

_CircuitsT = Union[List[QuantumCircuit], QuantumCircuit]
_CircuitsT = TypeVar("_CircuitsT", bound=Union[List[QuantumCircuit], QuantumCircuit])


class PassManager(BasePassManager):
Expand Down
8 changes: 1 addition & 7 deletions qiskit/visualization/circuit/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,7 @@ def __init__(
self._wire_map = {}
self.cregbundle = cregbundle

if encoding:
self.encoding = encoding
else:
if sys.stdout.encoding:
self.encoding = sys.stdout.encoding
else:
self.encoding = "utf8"
self.encoding = encoding or sys.stdout.encoding or "utf8"

self._nest_depth = 0 # nesting depth for control flow ops
self._expr_text = "" # expression text to display
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ black[jupyter]~=24.1
#
# These versions are pinned precisely because pylint frequently includes new
# on-by-default lint failures in new versions, which breaks our CI.
astroid==2.14.2
pylint==2.16.2
astroid==3.2.2
pylint==3.2.3
ruff==0.0.267


Expand Down

0 comments on commit 92e78ef

Please sign in to comment.