Skip to content

Commit

Permalink
Adding noqa as a TODO later on for onboarding to the tool. Will be fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Abe Coull committed Nov 8, 2023
1 parent 6d65f0c commit 71fe62e
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/braket/aws/aws_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def run(
**aws_quantum_task_kwargs,
)

def run_batch(
def run_batch( # noqa: D417
self,
task_specifications: Union[
Union[
Expand Down Expand Up @@ -406,7 +406,7 @@ def is_available(self) -> bool:

is_available_result = False

current_datetime_utc = datetime.utcnow()
current_datetime_utc = datetime.utcnow() # noqa: DTZ003
for execution_window in self.properties.service.executionWindows:
weekday = current_datetime_utc.weekday()
current_time_utc = current_datetime_utc.time().replace(microsecond=0)
Expand Down
4 changes: 2 additions & 2 deletions src/braket/aws/aws_quantum_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AwsQuantumTask(QuantumTask):
RESULTS_FILENAME = "results.json"

@staticmethod
def create(
def create( # noqa: D417
aws_session: AwsSession,
device_arn: str,
task_specification: Union[
Expand Down Expand Up @@ -673,7 +673,7 @@ def _(
DwaveAdvantageDeviceParameters,
Dwave2000QDeviceParameters,
],
_,
_, # noqa: ANN001
inputs: dict[str, float],
gate_definitions: Optional[dict[tuple[Gate, QubitSet], PulseSequence]],
*args,
Expand Down
2 changes: 1 addition & 1 deletion src/braket/aws/aws_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _add_braket_user_agents_handler(self, request: awsrequest.AWSRequest, **kwar
request.headers.add_header("User-Agent", self._braket_user_agents)

@staticmethod
def _add_cost_tracker_count_handler(request: awsrequest.AWSRequest, **kwargs) -> None:
def _add_cost_tracker_count_handler(request: awsrequest.AWSRequest, **kwargs) -> None: # noqa: ARG004
request.headers.add_header("Braket-Trackers", str(len(active_trackers())))

#
Expand Down
2 changes: 1 addition & 1 deletion src/braket/circuits/ascii_circuit_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _ascii_diagram_column(
# Determine if the qubit is part of the item or in the middle of a
# multi qubit item.
if qubit in target_qubits:
item_qubit_index = [
item_qubit_index = [ # noqa: RUF015
index for index, q in enumerate(target_qubits) if q == qubit
][0]
power_string = (
Expand Down
2 changes: 1 addition & 1 deletion src/braket/circuits/braket_program_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def is_builtin_gate(self, name: str) -> bool:
def add_phase_instruction(self, target: tuple[int], phase_value: int) -> None:
raise NotImplementedError

def add_gate_instruction(
def add_gate_instruction( # noqa: D417
self, gate_name: str, target: tuple[int], *params, ctrl_modifiers: list[int], power: float
) -> None:
"""Add Braket gate to the circuit.
Expand Down
6 changes: 3 additions & 3 deletions src/braket/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def register_subroutine(cls, func: SubroutineCallable) -> None:
Instruction('operator': 'H', 'target': QubitSet(Qubit(1),))
"""

def method_from_subroutine(self, *args, **kwargs) -> SubroutineReturn:
def method_from_subroutine(self, *args, **kwargs) -> SubroutineReturn: # noqa: ANN001
return self.add(func, *args, **kwargs)

function_name = func.__name__
Expand All @@ -114,7 +114,7 @@ def method_from_subroutine(self, *args, **kwargs) -> SubroutineReturn:
function_attr = getattr(cls, function_name)
function_attr.__doc__ = func.__doc__

def __init__(self, addable: AddableTypes | None = None, *args, **kwargs):
def __init__(self, addable: AddableTypes | None = None, *args, **kwargs): # noqa: D417
"""Inits a `Circuit`.
Args:
Expand Down Expand Up @@ -1002,7 +1002,7 @@ def apply_readout_noise(

return apply_noise_to_moments(self, noise, target_qubits, "readout")

def add(self, addable: AddableTypes, *args, **kwargs) -> Circuit:
def add(self, addable: AddableTypes, *args, **kwargs) -> Circuit: # noqa: D417
"""Generic add method for adding item(s) to self. Any arguments that
`add_circuit()` and / or `add_instruction()` and / or `add_result_type`
supports are supported by this method. If adding a
Expand Down
2 changes: 1 addition & 1 deletion src/braket/circuits/compiler_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def ascii_symbols(self) -> tuple[str, ...]:
"""tuple[str, ...]: Returns the ascii symbols for the compiler directive."""
return self._ascii_symbols

def to_ir(
def to_ir( # noqa: D417
self,
target: QubitSet | None = None,
ir_type: IRType = IRType.JAQCD,
Expand Down
6 changes: 3 additions & 3 deletions src/braket/circuits/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def to_matrix(self) -> np.ndarray:

@property
def basis_rotation_gates(self) -> tuple[Gate, ...]:
return tuple([Gate.Ry(-math.pi / 4)])
return tuple([Gate.Ry(-math.pi / 4)]) # noqa: C409


Observable.register_observable(H)
Expand Down Expand Up @@ -154,7 +154,7 @@ def to_matrix(self) -> np.ndarray:

@property
def basis_rotation_gates(self) -> tuple[Gate, ...]:
return tuple([Gate.H()])
return tuple([Gate.H()]) # noqa: C409


Observable.register_observable(X)
Expand Down Expand Up @@ -192,7 +192,7 @@ def to_matrix(self) -> np.ndarray:

@property
def basis_rotation_gates(self) -> tuple[Gate, ...]:
return tuple([Gate.Z(), Gate.S(), Gate.H()])
return tuple([Gate.Z(), Gate.S(), Gate.H()]) # noqa: C409


Observable.register_observable(Y)
Expand Down
2 changes: 1 addition & 1 deletion src/braket/circuits/result_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def name(self) -> str:
"""
return self.__class__.__name__

def to_ir(
def to_ir( # noqa: D417
self,
ir_type: IRType = IRType.JAQCD,
serialization_properties: SerializationProperties | None = None,
Expand Down
6 changes: 3 additions & 3 deletions src/braket/circuits/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import Union

import braket.circuits.gates as braket_gates
import braket.circuits.result_types as ResultTypes
import braket.circuits.result_types as ResultTypes # noqa: N812
import braket.ir.jaqcd.shared_models as models
from braket.circuits import Observable, noises, observables
from braket.ir.jaqcd import (
Expand Down Expand Up @@ -100,7 +100,7 @@ def _get_observable(obs: Union[models.Observable, list]) -> Observable:


@_get_observable.register(list)
def _(obs):
def _(obs): # noqa: ANN001
raise NotImplementedError


Expand All @@ -127,7 +127,7 @@ def _braket_result_to_result_type(result: Results) -> None:
raise TypeError(f"Result type {type(result).__name__} is not supported")


def braket_result_to_result_type(result: Results) -> None:
def braket_result_to_result_type(result: Results) -> None: # noqa: D103
return _braket_result_to_result_type(result)


Expand Down
2 changes: 1 addition & 1 deletion src/braket/devices/local_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def run(
result = self._run_internal(task_specification, shots, inputs=inputs, *args, **kwargs)
return LocalQuantumTask(result)

def run_batch(
def run_batch( # noqa: D417
self,
task_specifications: Union[
Union[Circuit, Problem, Program, AnalogHamiltonianSimulation],
Expand Down
2 changes: 1 addition & 1 deletion src/braket/jobs/hybrid_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def __enter__(self):
for module in self._modules:
cloudpickle.register_pickle_by_value(module)

def __exit__(self, exc_type, exc_val, exc_tb):
def __exit__(self, exc_type, exc_val, exc_tb): # noqa: ANN001
"""Unregister included modules with cloudpickle to be pickled by value"""
for module in self._modules:
cloudpickle.unregister_pickle_by_value(module)
Expand Down
2 changes: 1 addition & 1 deletion src/braket/jobs/local/local_job_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __enter__(self):
self._container_name = self._start_container(self.image_uri, self._force_update)
return self

def __exit__(self, exc_type, exc_val, exc_tb):
def __exit__(self, exc_type, exc_val, exc_tb): # noqa: ANN001
"""Stops and removes the local docker container."""
self._end_session()

Expand Down
2 changes: 1 addition & 1 deletion src/braket/jobs/quantum_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def result(
Raises:
RuntimeError: if hybrid job is in a FAILED or CANCELLED state.
TimeoutError: if hybrid job execution exceeds the polling timeout period.
"""
""" # noqa: D402

@abstractmethod
def download_result(
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extras = test
[testenv:linters]
basepython = python3
skip_install = true
# Remove this to check what versions are installed for the env.
list_dependencies_command = echo
deps =
{[testenv:ruff-format]deps}
Expand Down

0 comments on commit 71fe62e

Please sign in to comment.