From 71fe62eb7debdb44bb7696a02699aceb077c37f7 Mon Sep 17 00:00:00 2001 From: Abe Coull Date: Tue, 7 Nov 2023 16:34:41 -0800 Subject: [PATCH] Adding noqa as a TODO later on for onboarding to the tool. Will be fixed --- src/braket/aws/aws_device.py | 4 ++-- src/braket/aws/aws_quantum_task.py | 4 ++-- src/braket/aws/aws_session.py | 2 +- src/braket/circuits/ascii_circuit_diagram.py | 2 +- src/braket/circuits/braket_program_context.py | 2 +- src/braket/circuits/circuit.py | 6 +++--- src/braket/circuits/compiler_directive.py | 2 +- src/braket/circuits/observables.py | 6 +++--- src/braket/circuits/result_type.py | 2 +- src/braket/circuits/translations.py | 6 +++--- src/braket/devices/local_simulator.py | 2 +- src/braket/jobs/hybrid_job.py | 2 +- src/braket/jobs/local/local_job_container.py | 2 +- src/braket/jobs/quantum_job.py | 2 +- tox.ini | 1 + 15 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/braket/aws/aws_device.py b/src/braket/aws/aws_device.py index 4b78e83f7..1a953e4c5 100644 --- a/src/braket/aws/aws_device.py +++ b/src/braket/aws/aws_device.py @@ -203,7 +203,7 @@ def run( **aws_quantum_task_kwargs, ) - def run_batch( + def run_batch( # noqa: D417 self, task_specifications: Union[ Union[ @@ -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) diff --git a/src/braket/aws/aws_quantum_task.py b/src/braket/aws/aws_quantum_task.py index 951a07458..92832c681 100644 --- a/src/braket/aws/aws_quantum_task.py +++ b/src/braket/aws/aws_quantum_task.py @@ -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[ @@ -673,7 +673,7 @@ def _( DwaveAdvantageDeviceParameters, Dwave2000QDeviceParameters, ], - _, + _, # noqa: ANN001 inputs: dict[str, float], gate_definitions: Optional[dict[tuple[Gate, QubitSet], PulseSequence]], *args, diff --git a/src/braket/aws/aws_session.py b/src/braket/aws/aws_session.py index 8df8ac052..7ad193294 100644 --- a/src/braket/aws/aws_session.py +++ b/src/braket/aws/aws_session.py @@ -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()))) # diff --git a/src/braket/circuits/ascii_circuit_diagram.py b/src/braket/circuits/ascii_circuit_diagram.py index dc0ed1501..bb1a3ae9c 100644 --- a/src/braket/circuits/ascii_circuit_diagram.py +++ b/src/braket/circuits/ascii_circuit_diagram.py @@ -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 = ( diff --git a/src/braket/circuits/braket_program_context.py b/src/braket/circuits/braket_program_context.py index a03d45aa7..c19564529 100644 --- a/src/braket/circuits/braket_program_context.py +++ b/src/braket/circuits/braket_program_context.py @@ -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. diff --git a/src/braket/circuits/circuit.py b/src/braket/circuits/circuit.py index 696509bac..af2cab1cf 100644 --- a/src/braket/circuits/circuit.py +++ b/src/braket/circuits/circuit.py @@ -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__ @@ -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: @@ -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 diff --git a/src/braket/circuits/compiler_directive.py b/src/braket/circuits/compiler_directive.py index ad2c701c6..d0dc7d9d9 100644 --- a/src/braket/circuits/compiler_directive.py +++ b/src/braket/circuits/compiler_directive.py @@ -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, diff --git a/src/braket/circuits/observables.py b/src/braket/circuits/observables.py index 84ee888e8..d3617b337 100644 --- a/src/braket/circuits/observables.py +++ b/src/braket/circuits/observables.py @@ -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) @@ -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) @@ -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) diff --git a/src/braket/circuits/result_type.py b/src/braket/circuits/result_type.py index cd6342e93..46f94d76a 100644 --- a/src/braket/circuits/result_type.py +++ b/src/braket/circuits/result_type.py @@ -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, diff --git a/src/braket/circuits/translations.py b/src/braket/circuits/translations.py index 1b525c390..b30d2d870 100644 --- a/src/braket/circuits/translations.py +++ b/src/braket/circuits/translations.py @@ -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 ( @@ -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 @@ -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) diff --git a/src/braket/devices/local_simulator.py b/src/braket/devices/local_simulator.py index 2e457fff3..4bdc2896c 100644 --- a/src/braket/devices/local_simulator.py +++ b/src/braket/devices/local_simulator.py @@ -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], diff --git a/src/braket/jobs/hybrid_job.py b/src/braket/jobs/hybrid_job.py index be77ce600..a7b4fc3d4 100644 --- a/src/braket/jobs/hybrid_job.py +++ b/src/braket/jobs/hybrid_job.py @@ -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) diff --git a/src/braket/jobs/local/local_job_container.py b/src/braket/jobs/local/local_job_container.py index 3ca5f23a6..a90d481ed 100644 --- a/src/braket/jobs/local/local_job_container.py +++ b/src/braket/jobs/local/local_job_container.py @@ -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() diff --git a/src/braket/jobs/quantum_job.py b/src/braket/jobs/quantum_job.py index 32c660bcf..7e9f0b74f 100644 --- a/src/braket/jobs/quantum_job.py +++ b/src/braket/jobs/quantum_job.py @@ -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( diff --git a/tox.ini b/tox.ini index 0c1f84d86..a955bba2e 100644 --- a/tox.ini +++ b/tox.ini @@ -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}