Skip to content

Commit d741de5

Browse files
authored
Fix remaining pylint issues
Fixes all pylint issues that were commented in dev_tools/pylint fails with pylint-3 and later #210 except for line-too-long.
2 parents b185df6 + 96f6091 commit d741de5

9 files changed

Lines changed: 22 additions & 21 deletions

File tree

dev_tools/.pylintrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ enable=
1919
dangerous-default-value,
2020
docstyle,
2121
duplicate-argument-name,
22-
# expression-not-assigned, # TODO: #210 - enable and fix
22+
expression-not-assigned,
2323
f-string-without-interpolation,
24-
# function-redefined, # TODO: #210 - enable and fix
24+
function-redefined,
2525
inconsistent-mro,
2626
init-is-generator,
27-
# line-too-long, # TODO: #210 - enable and fix
27+
# line-too-long, # TODO: #210 - enable and fix
2828
lost-exception,
2929
missing-kwoa,
30-
# missing-param-doc, # TODO: #210 - enable and fix
30+
missing-param-doc,
3131
missing-raises-doc,
3232
mixed-line-endings,
33-
# no-value-for-parameter, # TODO: #210 - enable and fix
33+
no-value-for-parameter,
3434
nonexistent-operator,
3535
not-in-loop,
36-
# pointless-statement, # TODO: #210 - enable and fix
36+
pointless-statement,
3737
redefined-builtin,
3838
return-arg-in-generator,
3939
return-in-init,
4040
return-outside-function,
4141
simplifiable-if-statement,
4242
singleton-comparison,
4343
syntax-error,
44-
# too-many-function-args, # TODO: #210 - enable and fix
44+
too-many-function-args,
4545
trailing-whitespace,
4646
undefined-variable,
47-
# unexpected-keyword-arg, # TODO: #210 - enable and fix
47+
unexpected-keyword-arg,
4848
unhashable-dict-key,
4949
unnecessary-pass,
5050
unreachable,

dev_tools/write-ci-requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def main(
8585
out_fn: The output filename
8686
relative_cirq_version: Pin the desired cirq version to either "current", "previous",
8787
or "next" version.
88-
all_extras: Whether to include all the extras_require dependencies.
88+
all_extras: Whether to include all the extras_require dependencies.
8989
"""
9090
core_reqs = _parse_requirements(REPO_DIR / "requirements.txt")
9191
core_reqs = _set_cirq_version(core_reqs, relative_cirq_version)

examples/quantum_chinese_chess/move_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def test_slide_excluded_classical_source():
485485
)
486486

487487

488-
def test_slide_excluded_classical_source():
488+
def test_slide_excluded_quantum_source():
489489
"""Source in quantum state."""
490490
board = set_board(["a1", "b1", "c1"])
491491
world = board.board

examples/quantum_chinese_chess/test_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,4 @@ def assert_prob_about(
178178

179179
def assert_fifty_fifty(probabilities, that):
180180
"""Checks that the probability of `that` is close to 50%."""
181-
assert_prob_about(probabilities, that, 0.5), print_samples(
182-
list(probabilities.keys())
183-
)
181+
assert_prob_about(probabilities, that, 0.5)

unitary/alpha/quantum_object_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def test_negation(simulator, compile_to_qubits):
2828
piece, sampler=simulator(), compile_to_qubits=compile_to_qubits
2929
)
3030
assert board.peek() == [[0]]
31-
-piece
31+
-piece # pylint: disable=pointless-statement
3232
assert board.peek() == [[1]]
33-
-piece
33+
-piece # pylint: disable=pointless-statement
3434
assert board.peek() == [[0]]
3535
piece += 1
3636
assert board.peek() == [[1]]

unitary/alpha/qudit_gates.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ def _circuit_diagram_info_(self, args):
116116
)
117117

118118
def _with_exponent(self, exponent: float) -> "QuditRzGate":
119-
return QuditRzGate(rads=exponent * np.pi)
119+
return QuditRzGate(
120+
dimension=self.dimension,
121+
radians=exponent * np.pi,
122+
phased_state=self.phased_state,
123+
)
120124

121125

122126
class QuditPlusGate(cirq.Gate):

unitary/engine_utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ def run(
111111
program_id=_get_program_id(program),
112112
param_resolver=param_resolver,
113113
repetitions=repetitions,
114-
processor_ids=[self.processor_id],
115-
gate_set=self.gate_set,
114+
processor_id=self.processor_id,
116115
)
117116

118117
def run_sweep(
@@ -127,7 +126,6 @@ def run_sweep(
127126
program_id=_get_program_id(program),
128127
repetitions=repetitions,
129128
processor_ids=[self.processor_id],
130-
gate_set=self.gate_set,
131129
).results()
132130

133131
async def run_async(
@@ -139,7 +137,6 @@ async def run_async(
139137
program_id=program_id,
140138
repetitions=repetitions,
141139
processor_ids=[self.processor_id],
142-
gate_set=self.gate_set,
143140
)
144141
job = engine_job._refresh_job()
145142
while True:
@@ -258,7 +255,7 @@ def get_sampler(self, gateset: Optional[str] = None):
258255
@property
259256
def device_obj(self):
260257
dspec = self.engine.get_processor(self.processor_id).get_device_specification()
261-
device = cg.SerializableDevice.from_proto(proto=dspec, gate_sets=[])
258+
device = cg.SerializableDevice.from_proto(proto=dspec)
262259
return device
263260

264261

unitary/quantum_chess/circuit_transformer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def map_helper(
170170
graph: adjacency graph of connections between qubits,
171171
representing by a dictionary from qubit to adjacent qubits.
172172
nodes_trying: this list is used as a stack containing nodes currently under trying.
173+
print_debug: If true, prints out debug information.
173174
174175
Returns:
175176
True if mapping was successful, False if no mapping was possible.

unitary/quantum_chess/initial_mapping_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def traverse(
205205
Args:
206206
g: A logical qubits graph.
207207
s: The source qubit from which to start breadth-first search.
208+
visited: helper argument to keep track of visited nodes
208209
"""
209210
order = deque()
210211
if visited is None:

0 commit comments

Comments
 (0)