Skip to content

chore(typing): include samples in type checks #1455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ disable_error_code = [
# tableauserverclient\server\endpoint\datasources_endpoint.py:48: error: Cannot assign multiple types to name "FilePath" without an explicit "Type[...]" annotation [misc]
'annotation-unchecked' # can be removed when check_untyped_defs = true
]
files = ["tableauserverclient", "test"]
files = ["tableauserverclient", "test", "samples"]
show_error_codes = true
ignore_missing_imports = true # defusedxml library has no types
no_implicit_reexport = true
Expand Down
6 changes: 3 additions & 3 deletions samples/explore_favorites.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import argparse
import logging
import tableauserverclient as TSC
from tableauserverclient import Resource
from tableauserverclient.models import Resource


def main():
Expand Down Expand Up @@ -46,8 +46,8 @@ def main():
# get list of workbooks
all_workbook_items, pagination_item = server.workbooks.get()
if all_workbook_items is not None and len(all_workbook_items) > 0:
my_workbook: TSC.WorkbookItem = all_workbook_items[0]
server.favorites.add_favorite(server, user, Resource.Workbook.name(), all_workbook_items[0])
my_workbook = all_workbook_items[0]
server.favorites.add_favorite(user, Resource.Workbook, all_workbook_items[0])
print(
"Workbook added to favorites. Workbook Name: {}, Workbook ID: {}".format(
my_workbook.name, my_workbook.id
Expand Down
3 changes: 3 additions & 0 deletions samples/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def main():
"webhooks": server.webhooks,
"workbook": server.workbooks,
}.get(args.resource_type)
if endpoint is None:
print("Resource type not found.")
sys.exit(1)

options = TSC.RequestOptions()
options.sort.add(TSC.Sort(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Direction.Desc))
Expand Down
5 changes: 3 additions & 2 deletions tableauserverclient/models/favorites_item.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging

from typing import Union
from defusedxml.ElementTree import fromstring
from tableauserverclient.models.tableau_types import TableauItem

from tableauserverclient.models.tableau_types import TableauItem
from tableauserverclient.models.datasource_item import DatasourceItem
from tableauserverclient.models.flow_item import FlowItem
from tableauserverclient.models.project_item import ProjectItem
Expand All @@ -20,7 +21,7 @@

class FavoriteItem:
@classmethod
def from_response(cls, xml: str, namespace: dict) -> FavoriteType:
def from_response(cls, xml: Union[str, bytes], namespace: dict) -> FavoriteType:
favorites: FavoriteType = {
"datasources": [],
"flows": [],
Expand Down
Loading