8000 chore(typing): include samples in type checks (#1455) · TrimPeachu/server-client-python@2a7fb2b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a7fb2b

Browse files
jorwoodsjacalata
andauthored
chore(typing): include samples in type checks (tableau#1455)
* chore(typing): include samples in type checks Including the sample scripts in type checking will allow more thorough testing to validate the samples work as expected, as well as more testing around how a library consumer may use the library. --------- Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com> Co-authored-by: Jac <jacalata@users.noreply.github.com>
1 parent ac8dccd commit 2a7fb2b

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ disable_error_code = [
4646
# tableauserverclient\server\endpoint\datasources_endpoint.py:48: error: Cannot assign multiple types to name "FilePath" without an explicit "Type[...]" annotation [misc]
4747
'annotation-unchecked' # can be removed when check_untyped_defs = true
4848
]
49-
files = ["tableauserverclient", "test"]
49+
files = ["tableauserverclient", "test", "samples"]
5050
show_error_codes = true
5151
ignore_missing_imports = true # defusedxml library has no types
5252
no_implicit_reexport = true

samples/explore_favorites.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
import logging
55
import tableauserverclient as TSC
6-
from tableauserverclient import Resource
6+
from tableauserverclient.models import Resource
77

88

99
def main():
@@ -46,8 +46,8 @@ def main():
4646
# get list of workbooks
4747
all_workbook_items, pagination_item = server.workbooks.get()
4848
if all_workbook_items is not None and len(all_workbook_items) > 0:
49-
my_workbook: TSC.WorkbookItem = all_workbook_items[0]
50-
server.favorites.add_favorite(server, user, Resource.Workbook.name(), all_workbook_items[0])
49+
my_workbook = all_workbook_items[0]
50+
server.favorites.add_favorite(user, Resource.Workbook, all_workbook_items[0])
5151
print(
5252
"Workbook added to favorites. Workbook Name: {}, Workbook ID: {}".format(
5353
my_workbook.name, my_workbook.id

samples/list.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def main():
4848
"webhooks": server.webhooks,
4949
"workbook": server.workbooks,
5050
}.get(args.resource_type)
51+
if endpoint is None:
52+
print("Resource type not found.")
53+
sys.exit(1)
5154

5255
options = TSC.RequestOptions()
5356
options.sort.add(TSC.Sort(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Direction.Desc))

tableauserverclient/models/favorites_item.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logging
22

3+
from typing import Union
34
from defusedxml.ElementTree import fromstring
4-
from tableauserverclient.models.tableau_types import TableauItem
55

6+
from tableauserverclient.models.tableau_types import TableauItem
67
from tableauserverclient.models.datasource_item import DatasourceItem
78
from tableauserverclient.models.flow_item import FlowItem
89
from tableauserverclient.models.project_item import ProjectItem
@@ -20,7 +21,7 @@
2021

2122
class FavoriteItem:
2223
@classmethod
23-
def from_response(cls, xml: str, namespace: dict) -> FavoriteType:
24+
def from_response(cls, xml: Union[str, bytes], namespace: dict) -> FavoriteType:
2425
favorites: FavoriteType = {
2526
"datasources": [],
2627
"flows": [],

0 commit comments

Comments
 (0)
0