Skip to content

Commit

Permalink
Ruff enable flake8-comprehensions (C4) (#10339)
Browse files Browse the repository at this point in the history
* Ruff enable flake8-comprehensions (C4)

* add symbolic ruff rule id

---------

Co-authored-by: John Lapeyre <[email protected]>
  • Loading branch information
levbishop and jlapeyre authored Jun 28, 2023
1 parent 2ca4698 commit b73115f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/python/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

# Desired vector
print("Desired probabilities: ")
print(list(map(lambda x: format(abs(x * x), ".3f"), desired_vector)))
print([format(abs(x * x), ".3f") for x in desired_vector])

# Initialize on local simulator
sim_backend = BasicAer.get_backend("qasm_simulator")
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repair-wheel-command = "cp {wheel} {dest_dir}/. && pipx run abi3audit --strict -

[tool.ruff]
select = [
"C4", # category: flake8-comprehensions
"F631",
"F632",
"F634",
Expand Down
2 changes: 1 addition & 1 deletion qiskit/pulse/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _measure_v2(
meas_group = set()
for qubit in qubits:
meas_group |= set(meas_map[qubit])
meas_group = sorted(list(meas_group))
meas_group = sorted(meas_group)

meas_group_set = set(range(max(meas_group) + 1))
unassigned_qubit_indices = sorted(set(meas_group) - qubit_mem_slots.keys())
Expand Down
2 changes: 1 addition & 1 deletion qiskit/qobj/converters/pulse_instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def _convert_parametric_pulse(
try:
pulse_name = instruction.label
except AttributeError:
sorted_params = sorted(tuple(instruction.parameters.items()), key=lambda x: x[0])
sorted_params = sorted(instruction.parameters.items(), key=lambda x: x[0])
base_str = "{pulse}_{params}".format(
pulse=instruction.pulse_shape, params=str(sorted_params)
)
Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def connected_components(self) -> List["CouplingMap"]:
output_list = []
for component in components:
new_cmap = CouplingMap()
new_cmap.graph = self.graph.subgraph(list(sorted(component)))
new_cmap.graph = self.graph.subgraph(sorted(component))
output_list.append(new_cmap)
return output_list

Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/passes/layout/disjoint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def separate_dag(dag: DAGCircuit) -> List[DAGCircuit]:
connected_components = rx.weakly_connected_components(im_graph)
component_qubits = []
for component in connected_components:
component_qubits.append(set(qubit_map[x] for x in component))
component_qubits.append({qubit_map[x] for x in component})

qubits = set(dag.qubits)

Expand Down
2 changes: 1 addition & 1 deletion test/python/pulse/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ def _filter_and_test_consistency(
excluded = sched_blk.exclude(*args, **kwargs)

def list_instructions(blk: pulse.ScheduleBlock) -> List[pulse.Instruction]:
insts = list()
insts = []
for element in blk.blocks:
if isinstance(element, pulse.ScheduleBlock):
inner_insts = list_instructions(element)
Expand Down

0 comments on commit b73115f

Please sign in to comment.