8000 Fix type annotations on Job endpoint · tableau/server-client-python@16469c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 16469c3

Browse files
committed
Fix type annotations on Job endpoint
1 parent d58e372 commit 16469c3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tableauserverclient/server/endpoint/jobs_endpoint.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
logger = logging.getLogger("tableau.endpoint.jobs")
1010

11-
from typing import List, Optional, Tuple, TYPE_CHECKING, TypeVar
11+
from typing import List, Optional, Tuple, TYPE_CHECKING, Union
1212

13-
T = TypeVar("T", int, float)
1413

1514

1615
class Jobs(Endpoint):
@@ -38,9 +37,11 @@ def get(
3837
return jobs, pagination_item
3938

4039
@api(version="3.1")
41-
def cancel(self, job_id: str):
42-
id_ = getattr(job_id, "id", job_id)
43-
url = "{0}/{1}".format(self.baseurl, id_)
40+
def cancel(self, job_id: Union[str, JobItem]):
41+
if isinstance(job_id, JobItem):
42+
job_id = job_id.id
43+
assert isinstance(job_id, str)
44+
url = "{0}/{1}".format(self.baseurl, job_id)
4445
return self.put_request(url)
4546

4647
@api(version="2.6")
@@ -51,7 +52,7 @@ def get_by_id(self, job_id: str) -> JobItem:
5152
new_job = JobItem.from_response(server_response.content, self.parent_srv.namespace)[0]
5253
return new_job
5354

54-
def wait_for_job(self, job_id: str, *, timeout: Optional[T] = None) -> JobItem:
55+
def wait_for_job(self, job_id: Union[str, JobItem], *, timeout: Optional[float] = None) -> JobItem:
5556
if isinstance(job_id, JobItem):
5657
job_id = job_id.id
5758
assert isinstance(job_id, str)

0 commit comments

Comments
 (0)
0