Repository: Qiskit/qiskit

Issue:
Bump pylint version used to latest release
<!--
⚠️ If you do not respect this template, your pull request will be closed.
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ Also, please add a release note file using reno if the change needs to be
  documented in the release notes.
⚠️ If your pull request fixes an open issue, please link to the issue.

- [ ] I have added the tests to cover my changes.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
-->

### Summary

The pinned version of pylint we're running in CI right now doesn't support Python 3.12. This is an issue if you're developing with Python 3.12 because you couldn't run pylint. This commit bumps to the latest version as of this commit and fixes the additional checks flagged by the newer version.

### Details and comments
AttributeError when running pylint in python 3.12
### Environment

- **Qiskit version**:  1.2.0
- **Python version**:  3.12.1
- **Operating system**:  Windows 11


### What is happening?

When I try to run `tox -elint` after modifying some files locally this is what happens:
- black runs successfully
- ruff runs successfully
- pylint throws error!!

The error that I'm getting is not due to some linting issues in my code but instead its an 
`AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias'` 
I should mention that I am not getting any error when installing the editable version of `qiskit` after cloning the repo. So the source of this error is not due to some installation problem.

I did some google search and I found this issue on `pylint-dev` [github page](https://github.com/pylint-dev/pylint/issues/8782). Apparently this is an issue that is related to python 3.12 and this issue has been fixed sometime in August 2023. But the pylint version that we use from `requirements-dev.txt` is `pylint==2.16.2` (released in Feb 2023). Can we update the pylint version that `requirements-dev.txt` has (I know this is an involved task) because `qiskit` now supports python 3.12.

Let me know if you want the full error message, I'm not including that full error message here becasue it is very very long!

### How can we reproduce the issue?

Run `tox -elint` on the qiskit code in python 3.12.1 virtual environment.

### What should happen?

The command `tox -elint` should not give any AttributeError.

### Any suggestions?

Maybe we will have to upgrade `pylint` to a version that was probably released after August 2023 (this is when this issue was fixed on pylint-dev repo, see the link in the description)


Discussion:

One or more of the the following people are requested to review this:
- @enavarro51
- `@Qiskit/terra-core`

Marking as on hold until after 1.1.0rc1 so we don't disrupt pending PRs


Resolving patch:
diff --git a/qiskit/transpiler/passmanager.py b/qiskit/transpiler/passmanager.py
--- a/qiskit/transpiler/passmanager.py
+++ b/qiskit/transpiler/passmanager.py
@@ -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
@@ -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):
diff --git a/qiskit/visualization/circuit/text.py b/qiskit/visualization/circuit/text.py
--- a/qiskit/visualization/circuit/text.py
+++ b/qiskit/visualization/circuit/text.py
@@ -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


Test patch: