Skip to content

Commit

Permalink
Provide return annotations to all providers.JobV1.result() methods (#…
Browse files Browse the repository at this point in the history
…11531)

* Make providers.JobV1 generic on result() return

Makes `JobV1` a `Generic[T]` class where `T` is the return type of the
`run()` method. The intended value is to allow tools such as the primitives
to be more explicit about what the jobs they return will contain.

* Remove future import

* alphebetize imports

* switch to covariant TypeVar

* remove generic and just use Result

* avoid circular import

* fix circular imports attempt 2
  • Loading branch information
ihincks authored Jan 11, 2024
1 parent b8d21ae commit 3c538f3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qiskit/providers/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@

"""Job abstract interface."""

from __future__ import annotations

import time
from abc import ABC, abstractmethod
from typing import Callable, Optional
from typing import Callable, Optional, TYPE_CHECKING

from qiskit.exceptions import QiskitError
from qiskit.providers.backend import Backend
from qiskit.providers.exceptions import JobTimeoutError
from qiskit.providers.jobstatus import JOB_FINAL_STATES, JobStatus

if TYPE_CHECKING:
from qiskit.result import Result


class Job:
"""Base common type for all versioned Job abstract classes.
Expand Down Expand Up @@ -128,7 +133,7 @@ def submit(self):
pass

@abstractmethod
def result(self):
def result(self) -> Result:
"""Return the results of the job."""
pass

Expand All @@ -137,6 +142,6 @@ def cancel(self):
raise NotImplementedError

@abstractmethod
def status(self):
def status(self) -> JobStatus:
"""Return the status of the job, among the values of ``JobStatus``."""
pass

0 comments on commit 3c538f3

Please sign in to comment.