Skip to content

Commit 1dae57c

Browse files
vincentmrgithub-actions[bot]rashidnhm
authored
Fix isort config (#647)
* Fix isort pyver and length * Auto update version * Update changelog. * Use isort GHA. * Specify -p pennylane_lightning * Use black GHA * isort --check --diff * Revert test change. * sort fields. * Update .github/workflows/format.yml Co-authored-by: Rashid N H M <[email protected]> * Update .github/workflows/format.yml Co-authored-by: Rashid N H M <[email protected]> * Auto update version * trigger ci * trigger ci * Use format-python in format.yml. * Auto update version * trigger ci --------- Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com> Co-authored-by: Rashid N H M <[email protected]>
1 parent c82198b commit 1dae57c

File tree

10 files changed

+24
-39
lines changed

10 files changed

+24
-39
lines changed

.github/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
### Bug fixes
4343

44+
* Specify `isort` `--py` (Python version) and `-l` (max line length) to stabilize `isort` across Python versions and environments.
45+
[(#647)](https://github.com/PennyLaneAI/pennylane-lightning/pull/647)
46+
4447
* Fix random `coverage xml` CI issues.
4548
[(#635)](https://github.com/PennyLaneAI/pennylane-lightning/pull/635)
4649

.github/workflows/format.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ jobs:
2626
- name: Checkout PennyLane-Lightning
2727
uses: actions/checkout@v3
2828

29-
- name: Run isort
30-
run: python -m isort --profile black ./pennylane_lightning/ ./mpitests ./tests --check --diff
31-
32-
- name: Run Black
33-
run: python -m black -l 100 pennylane_lightning/ tests/ --check --verbose
29+
- name: Run isort & black --check
30+
run: make format-python check=1 verbose=1
3431

3532
format-cpp:
3633
name: Format (C++)
@@ -62,7 +59,7 @@ jobs:
6259
- name: Set up Python
6360
uses: actions/setup-python@v4
6461
with:
65-
python-version: '3.9'
62+
python-version: '3.11'
6663

6764
- name: Install dependencies
6865
run: sudo apt update && sudo apt -y install cmake gcc-11 g++-11 ninja-build libomp-14-dev && python -m pip install -r requirements-dev.txt

Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ TESTRUNNER := -m pytest tests --tb=short
55
PL_BACKEND ?= "$(if $(backend:-=),$(backend),lightning_qubit)"
66

77
ifdef check
8-
CHECK := --check
8+
CHECK := --check --diff
9+
ICHECK := --check
910
else
1011
CHECK :=
12+
ICHECK :=
1113
endif
1214

1315
ifdef build_options
@@ -113,8 +115,8 @@ format-cpp:
113115
./bin/format $(CHECK) ./pennylane_lightning
114116

115117
format-python:
116-
isort --profile black ./pennylane_lightning/ ./mpitests ./tests $(CHECK)
117-
black -l 100 ./pennylane_lightning/ ./mpitests ./tests $(CHECK)
118+
isort --py 311 --profile black -l 100 -p pennylane_lightning ./pennylane_lightning/ ./mpitests ./tests $(ICHECK) $(VERBOSE)
119+
black -l 100 ./pennylane_lightning/ ./mpitests ./tests $(CHECK) $(VERBOSE)
118120

119121
.PHONY: check-tidy
120122
check-tidy:

pennylane_lightning/core/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
Version number (major.minor.patch[-label])
1717
"""
1818

19-
__version__ = "0.36.0-dev14"
19+
__version__ = "0.36.0-dev15"

pennylane_lightning/lightning_gpu/lightning_gpu.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
from pennylane.ops.op_math import Adjoint
9292
from pennylane.wires import Wires
9393

94+
# pylint: disable=import-error, no-name-in-module, ungrouped-imports
95+
from pennylane_lightning.core._serialize import QuantumScriptSerializer, global_phase_diagonal
96+
from pennylane_lightning.core._version import __version__
97+
9498
# pylint: disable=no-name-in-module, ungrouped-imports
9599
from pennylane_lightning.lightning_gpu_ops.algorithms import (
96100
AdjointJacobianC64,
@@ -99,13 +103,6 @@
99103
create_ops_listC128,
100104
)
101105

102-
# pylint: disable=import-error, no-name-in-module, ungrouped-imports
103-
from pennylane_lightning.core._serialize import (
104-
QuantumScriptSerializer,
105-
global_phase_diagonal,
106-
)
107-
from pennylane_lightning.core._version import __version__
108-
109106
if MPI_SUPPORT:
110107
from pennylane_lightning.lightning_gpu_ops.algorithmsMPI import (
111108
AdjointJacobianMPIC64,

pennylane_lightning/lightning_kokkos/lightning_kokkos.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
from pennylane.ops.op_math import Adjoint
6565
from pennylane.wires import Wires
6666

67+
# pylint: disable=import-error, no-name-in-module, ungrouped-imports
68+
from pennylane_lightning.core._serialize import QuantumScriptSerializer, global_phase_diagonal
69+
from pennylane_lightning.core._version import __version__
70+
6771
# pylint: disable=import-error, no-name-in-module, ungrouped-imports
6872
from pennylane_lightning.lightning_kokkos_ops.algorithms import (
6973
AdjointJacobianC64,
@@ -72,13 +76,6 @@
7276
create_ops_listC128,
7377
)
7478

75-
# pylint: disable=import-error, no-name-in-module, ungrouped-imports
76-
from pennylane_lightning.core._serialize import (
77-
QuantumScriptSerializer,
78-
global_phase_diagonal,
79-
)
80-
from pennylane_lightning.core._version import __version__
81-
8279
def _kokkos_dtype(dtype):
8380
if dtype not in [np.complex128, np.complex64]: # pragma: no cover
8481
raise ValueError(f"Data type is not supported for state-vector computation: {dtype}")

pennylane_lightning/lightning_qubit/_measurements.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
# pylint: disable=import-error, no-name-in-module, ungrouped-imports
1919
try:
20-
from pennylane_lightning.lightning_qubit_ops import (
21-
MeasurementsC64,
22-
MeasurementsC128,
23-
)
20+
from pennylane_lightning.lightning_qubit_ops import MeasurementsC64, MeasurementsC128
2421
except ImportError:
2522
pass
2623

tests/lightning_qubit/test_adjoint_jacobian_class.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
from pennylane.tape import QuantumScript
2424
from scipy.stats import unitary_group
2525

26-
from pennylane_lightning.lightning_qubit._adjoint_jacobian import (
27-
LightningAdjointJacobian,
28-
)
26+
from pennylane_lightning.lightning_qubit._adjoint_jacobian import LightningAdjointJacobian
2927
from pennylane_lightning.lightning_qubit._state_vector import LightningStateVector
3028

3129
if not LightningDevice._new_API:

tests/lightning_qubit/test_measurements_class.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
from scipy.sparse import csr_matrix, random_array
2727

2828
try:
29-
from pennylane_lightning.lightning_qubit_ops import (
30-
MeasurementsC64,
31-
MeasurementsC128,
32-
)
29+
from pennylane_lightning.lightning_qubit_ops import MeasurementsC64, MeasurementsC128
3330
except ImportError:
3431
pass
3532

tests/test_serialize.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
import pytest
2020
from conftest import LightningDevice, device_name
2121

22-
from pennylane_lightning.core._serialize import (
23-
QuantumScriptSerializer,
24-
global_phase_diagonal,
25-
)
22+
from pennylane_lightning.core._serialize import QuantumScriptSerializer, global_phase_diagonal
2623

2724
if not LightningDevice._CPP_BINARY_AVAILABLE:
2825
pytest.skip("No binary module found. Skipping.", allow_module_level=True)

0 commit comments

Comments
 (0)