8000 Incorporate PR feedback · tableau/server-client-python@2907d5d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2907d5d

Browse files
committed
Incorporate PR feedback
1 parent 514cc13 commit 2907d5d

36 files changed

+1
-53
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = "README.md"
1313

1414
dependencies = [
1515
'defusedxml>=0.7.1',
16-
'packaging~=21.3',
16+
'packaging>=22.0', # bumping to minimum version required by black
1717
'requests>=2.28',
1818
'urllib3~=1.26.8',
1919
]

samples/add_default_permission.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def main():
4646
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
4747
server = TSC.Server(args.server, use_server_version=True)
4848
with server.auth.sign_in(tableau_auth):
49-
5049
# Create a sample project
5150
project = TSC.ProjectItem("sample_project")
5251
project = server.projects.create(project)

samples/create_group.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
def main():
21-
2221
parser = argparse.ArgumentParser(description="Creates a sample user group.")
2322
# Common options; please keep those in sync across all samples
2423
parser.add_argument("--server", "-s", required=True, help="server address")

samples/create_schedules.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
def main():
18-
1918
parser = argparse.ArgumentParser(description="Creates sample schedules for each type of frequency.")
2019
# Common options; please keep those in sync across all samples
2120
parser.add_argument("--server", "-s", required=True, help="server address")

samples/explore_datasource.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
def main():
19-
2019
parser = argparse.ArgumentParser(description="Explore datasource functions supported by the Server API.")
2120
# Common options; please keep those in sync across all samples
2221
parser.add_argument("--server", "-s", required=True, help="server address")

samples/explore_site.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
def main():
15-
1615
parser = argparse.ArgumentParser(description="Explore site updates by the Server API.")
1716
# Common options; please keep those in sync across all samples
1817
parser.add_argument("--server", "-s", required=True, help="server address")

samples/explore_webhooks.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
def main():
20-
2120
parser = argparse.ArgumentParser(description="Explore webhook functions supported by the Server API.")
2221
# Common options; please keep those in sync across all samples
2322
parser.add_argument("--server", "-s", required=True, help="server address")
@@ -49,10 +48,8 @@ def main():
4948
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
5049
server = TSC.Server(args.server, use_server_version=True)
5150
with server.auth.sign_in(tableau_auth):
52-
5351
# Create webhook if create flag is set (-create, -c)
5452
if args.create:
55-
5653
new_webhook = TSC.WebhookItem()
5754
new_webhook.name = args.create
5855
new_webhook.url = "https://ifttt.com/maker-url"

samples/explore_workbook.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
def main():
20-
2120
parser = argparse.ArgumentParser(description="Explore workbook functions supported by the Server API.")
2221
# Common options; please keep those in sync across all samples
2322
parser.add_argument("--server", "-s", required=True, help="server address")
@@ -52,7 +51,6 @@ def main():
5251
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
5352
server = TSC.Server(args.server, use_server_version=True)
5453
with server.auth.sign_in(tableau_auth):
55-
5654
# Publish workbook if publish flag is set (-publish, -p)
5755
overwrite_true = TSC.Server.PublishMode.Overwrite
5856
if args.publish:

samples/extracts.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
def main():
20-
2120
parser = argparse.ArgumentParser(description="Explore extract functions supported by the Server API.")
2221
# Common options; please keep those in sync across all samples
2322
parser.add_argument("--server", "-s", required=True, help="server address")
@@ -50,7 +49,6 @@ def main():
5049
server.add_http_options({"verify": False})
5150
server.use_server_version()
5251
with server.auth.sign_in(tableau_auth):
53-
5452
# Gets all workbook items
5553
all_workbooks, pagination_item = server.workbooks.get()
5654
print("\nThere are {} workbooks on site: ".format(pagination_item.total_available))

samples/filter_sort_groups.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def main():
5353
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
5454
server = TSC.Server(args.server, use_server_version=True)
5555
with server.auth.sign_in(tableau_auth):
56-
5756
group_name = "SALES NORTHWEST"
5857
# Try to create a group named "SALES NORTHWEST"
5958
create_example_group(group_name, server)

samples/filter_sort_projects.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def create_example_project(
1818
description="Project created for testing",
1919
server=None,
2020
):
21-
2221
new_project = TSC.ProjectItem(name=name, content_permissions=content_permissions, description=description)
2322
try:
2423
server.projects.create(new_project)

samples/initialize_server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def main():
4545
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
4646
server = TSC.Server(args.server, use_server_version=True)
4747
with server.auth.sign_in(tableau_auth):
48-
4948
################################################################################
5049
# Step 2: Create the site we need only if it doesn't exist
5150
################################################################################
@@ -75,7 +74,6 @@ def main():
7574
tableau_auth.site_id = args.site_id
7675

7776
with server_upload.auth.sign_in(tableau_auth):
78-
7977
################################################################################
8078
# Step 4: Create the project we need only if it doesn't exist
8179
################################################################################

samples/login.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def sample_define_common_options(parser):
4848

4949

5050
def sample_connect_to_server(args):
51-
5251
if args.username:
5352
# Trying to authenticate using username and password.
5453
password = args.password or getpass.getpass("Password: ")

samples/move_workbook_projects.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
def main():
18-
1918
parser = argparse.ArgumentParser(description="Move one workbook from the default project to another.")
2019
# Common options; please keep those in sync across all samples
2120
parser.add_argument("--server", "-s", required=True, help="server address")

samples/move_workbook_sites.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
def main():
19-
2019
parser = argparse.ArgumentParser(
2120
description="Move one workbook from the"
2221
"default project of the default site to"
@@ -84,7 +83,6 @@ def main():
8483
# Signing into another site requires another server object
8584
# because of the different auth token and site ID.
8685
with dest_server.auth.sign_in(tableau_auth):
87-
8886
# Step 5: Create a new workbook item and publish workbook. Note that
8987
# an empty project_id will publish to the 'Default' project.
9088
new_workbook = TSC.WorkbookItem(name=args.workbook_name, project_id="")

samples/pagination_sample.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
def main():
21-
2221
parser = argparse.ArgumentParser(description="Demonstrate pagination on the list of workbooks on the server.")
2322
# Common options; please keep those in sync across all samples
2423
parser.add_argument("--server", "-s", required=True, help="server address")

samples/publish_workbook.py

Lines changed: 0 additions & 2 deletions
< 10000 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323

2424
def main():
25-
2625
parser = argparse.ArgumentParser(description="Publish a workbook to server.")
2726
# Common options; please keep those in sync across all samples
2827
parser.add_argument("--server", "-s", required=True, help="server address")
@@ -55,7 +54,6 @@ def main():
5554
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
5655
server = TSC.Server(args.server, use_server_version=True)
5756
with server.auth.sign_in(tableau_auth):
58-
5957
# Step 2: Get all the projects on server, then look for the default one.
6058
all_projects, pagination_item = server.projects.get()
6159
default_project = next((project for project in all_projects if project.is_default()), None)

samples/query_permissions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def main():
4444
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
4545
server = TSC.Server(args.server, use_server_version=True)
4646
with server.auth.sign_in(tableau_auth):
47-
4847
# Mapping to grab the handler for the user-inputted resource type
4948
endpoint = {
5049
"workbook": server.workbooks,

tableauserverclient/models/connection_item.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def from_xml_element(cls, parsed_response, ns) -> List["ConnectionItem"]:
8585
connection_credentials = connection_xml.find(".//t:connectionCredentials", namespaces=ns)
8686

8787
if connection_credentials is not None:
88-
8988
connection_item.connection_credentials = ConnectionCredentials.from_xml_element(
9089
connection_credentials, ns
9190
)

tableauserverclient/models/group_item.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class GroupItem(object):
15-
1615
tag_name: str = "group"
1716

1817
class LicenseMode:

tableauserverclient/models/interval_item.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class Day:
2727

2828
class HourlyInterval(object):
2929
def __init__(self, start_time, end_time, interval_value):
30-
3130
self.start_time = start_time
3231
self.end_time = end_time
3332
self.interval = interval_value
@@ -70,7 +69,6 @@ def interval(self, interval):
7069
self._interval = interval
7170

7271
def _interval_type_pairs(self):
73-
7472
# We use fractional hours for the two minute-based intervals.
7573
# Need to convert to minutes from hours here
7674
if self.interval in {0.25, 0.5}:

tableauserverclient/models/property_decorators.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def wrapper(self, value):
101101

102102

103103
def property_matches(regex_to_match, error):
104-
105104
compiled_re = re.compile(regex_to_match)
106105

107106
def wrapper(func):

tableauserverclient/models/table_item.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ def from_response(cls, resp, ns):
140140

141141
@staticmethod
142142
def _parse_element(table_xml, ns):
143-
144143
table_values = table_xml.attrib.copy()
145144

146145
contact = table_xml.find(".//t:contact", namespaces=ns)

tableauserverclient/models/user_item.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
class UserItem(object):
24-
2524
tag_name: str = "user"
2625

2726
class Roles:

tableauserverclient/server/endpoint/datasources_endpoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ def publish(
199199
connections: Optional[Sequence[ConnectionItem]] = None,
200200
as_job: bool = False,
201201
) -> Union[DatasourceItem, JobItem]:
202-
203202
if isinstance(file, (os.PathLike, str)):
204203
if not os.path.isfile(file):
205204
error = "File path does not lead to an existing file."

tableauserverclient/server/endpoint/schedules_endpoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def add_to_schedule(
9090
flow: Optional["FlowItem"] = None,
9191
task_type: Optional[str] = None,
9292
) -> List[AddResponse]:
93-
9493
# There doesn't seem to be a good reason to allow one item of each type?
9594
if workbook and datasource:
9695
warnings.warn("Passing in multiple items for add_to_schedule will be deprecated", PendingDeprecationWarning)

tableauserverclient/server/endpoint/workbooks_endpoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ def publish(
319319
hidden_views: Optional[Sequence[str]] = None,
320320
skip_connection_check: bool = False,
321321
):
322-
323322
if connection_credentials is not None:
324323
import warnings
325324

tableauserverclient/server/pager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class Pager(object):
1313
"""
1414

1515
def __init__(self, endpoint, request_opts=None, **kwargs):
16-
1716
if hasattr(endpoint, "get"):
1817
# The simpliest case is to take an Endpoint and call its get
1918
endpoint = partial(endpoint.get, **kwargs)

test/test_datasource.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ def test_publish_hyper_file_object_raises_exception(self) -> None:
542542
)
543543

544544
def test_publish_tde_file_object_raises_exception(self) -> None:
545-
546545
new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "test")
547546
tds_asset = asset(os.path.join("Data", "Tableau Samples", "World Indicators.tde"))
548547
with open(tds_asset, "rb") as file_object:

test/test_endpoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def test_get_request_stream(self) -> None:
2929

3030
def test_binary_log_truncated(self):
3131
class FakeResponse(object):
32-
3332
headers = {"Content-Type": "application/octet-stream"}
3433
content = b"\x1337" * 1000
3534
status_code = 200

test/test_filesys_helpers.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
class FilesysTests(unittest.TestCase):
1212
def test_get_file_size_returns_correct_size(self):
13-
1413
target_size = 1000 # bytes
1514

1615
with BytesIO() as f:
@@ -21,14 +20,12 @@ def test_get_file_size_returns_correct_size(self):
2120
self.assertEqual(file_size, target_size)
2221

2322
def test_get_file_size_returns_zero_for_empty_file(self):
24-
2523
with BytesIO() as f:
2624
file_size = get_file_object_size(f)
2725

2826
self.assertEqual(file_size, 0)
2927

3028
def test_get_file_size_coincides_with_built_in_method(self):
31-
3229
asset_path = asset("SampleWB.twbx")
3330
target_size = os.path.getsize(asset_path)
3431
with open(asset_path, "rb") as f:
@@ -37,7 +34,6 @@ def test_get_file_size_coincides_with_built_in_method(self):
3734
self.assertEqual(file_size, target_size)
3835

3936
def test_get_file_type_identifies_a_zip_file(self):
40-
4137
with BytesIO() as file_object:
4238
with ZipFile(file_object, "w") as zf:
4339
with BytesIO() as stream:
@@ -59,7 +55,6 @@ def test_get_file_type_identifies_twbx_as_zip_file(self):
5955
self.assertEqual(file_type, "zip")
6056

6157
def test_get_file_type_identifies_xml_file(self):
62-
6358
root = ET.Element("root")
6459
child = ET.SubElement(root, "child")
6560
child.text = "This is a child element"
@@ -95,7 +90,6 @@ def test_get_file_type_identifies_tde_file(self):
9590
self.assertEqual(file_type, "tde")
9691

9792
def test_get_file_type_handles_unknown_file_type(self):
98-
9993
# Create a dummy png file
10094
with BytesIO() as file_object:
10195
png_signature = bytes.fromhex("89504E470D0A1A0A")

test/test_flow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ def test_publish_file_object(self) -> None:
174174
publish_mode = self.server.PublishMode.CreateNew
175175

176176
with open(sample_flow, "rb") as fp:
177-
178177
publish_mode = self.server.PublishMode.CreateNew
179178

180179
new_flow = self.server.flows.publish(new_flow, fp, publish_mode)

test/test_project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def test_update_missing_id(self) -> None:
139139
self.assertRaises(TSC.MissingRequiredFieldError, self.server.projects.update, single_project)
140140

141141
def test_create(self) -> None:
142-
143142
with open(CREATE_XML, "rb") as f:
144143
response_xml = f.read().decode("utf-8")
145144
with requests_mock.mock() as m:

test/test_site_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def test_invalid_admin_mode(self):
2222
site.admin_mode = "Hello"
2323

2424
def test_invalid_content_url(self):
25-
2625
with self.assertRaises(ValueError):
2726
site = TSC.SiteItem(name="蚵仔煎", content_url="蚵仔煎")
2827

test/test_user_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def test_invalid_site_role(self):
3232

3333

3434
class UserDataTest(unittest.TestCase):
35-
3635
logger = logging.getLogger("UserDataTest")
3736

3837
role_inputs = [

0 commit comments

Comments
 (0)
0