8000 chore(versions): Upgrade minimum python version by jorwoods · Pull Request #1465 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

chore(versions): Upgrade minimum python version #1465

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 6 commits into from
Sep 19, 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 .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13-dev']

runs-on: ${{ matrix.os }}

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ dependencies = [
'urllib3==2.2.2', # dependabot
'typing_extensions>=4.0.1',
]
requires-python = ">=3.7"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]
[project.urls]
repository = "https://github.com/tableau/server-client-python"

[project.optional-dependencies]
test = ["black==23.7", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
test = ["black==24.8", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
"requests-mock>=1.0,<2.0"]

[tool.black]
line-length = 120
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']

[tool.mypy]
check_untyped_defs = false
Expand Down
4 changes: 2 additions & 2 deletions samples/add_default_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def main():
for permission in new_default_permissions:
grantee = permission.grantee
capabilities = permission.capabilities
print("\nCapabilities for {0} {1}:".format(grantee.tag_name, grantee.id))
print(f"\nCapabilities for {grantee.tag_name} {grantee.id}:")

for capability in capabilities:
print("\t{0} - {1}".format(capability, capabilities[capability]))
print(f"\t{capability} - {capabilities[capability]}")

# Uncomment lines below to DELETE the new capability and the new project
# rules_to_delete = TSC.PermissionsRule(
Expand Down
13 changes: 6 additions & 7 deletions samples/create_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import os

from datetime import time
from typing import List

import tableauserverclient as TSC
from tableauserverclient import ServerResponseError
Expand Down Expand Up @@ -63,23 +62,23 @@ def main():

if args.file:
filepath = os.path.abspath(args.file)
print("Add users to site from file {}:".format(filepath))
added: List[TSC.UserItem]
failed: List[TSC.UserItem, TSC.ServerResponseError]
print(f"Add users to site from file {filepath}:")
added: list[TSC.UserItem]
failed: list[TSC.UserItem, TSC.ServerResponseError]
added, failed = server.users.create_from_file(filepath)
for user, error in failed:
print(user, error.code)
if error.code == "409017":
user = server.users.filter(name=user.name)[0]
added.append(user)
print("Adding users to group:{}".format(added))
print(f"Adding users to group:{added}")
for user in added:
print("Adding user {}".format(user))
print(f"Adding user {user}")
try:
server.groups.add_user(group, user.id)
except ServerResponseError as serverError:
if serverError.code == "409011":
print("user {} is already a member of group {}".format(user.name, group.name))
print(f"user {user.name} is already a member of group {group.name}")
else:
raise rError

Expand Down
2 changes: 1 addition & 1 deletion samples/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def main():
server.projects.populate_datasource_default_permissions(changed_project),
server.projects.populate_permissions(changed_project)
# Projects have default permissions set for the object types they contain
print("Permissions from project {}:".format(changed_project.id))
print(f"Permissions from project {changed_project.id}:")
print(changed_project.permissions)
print(
changed_project.default_workbook_permissions,
Expand Down
8 changes: 4 additions & 4 deletions samples/create_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():
)
try:
hourly_schedule = server.schedules.create(hourly_schedule)
print("Hourly schedule created (ID: {}).".format(hourly_schedule.id))
print(f"Hourly schedule created (ID: {hourly_schedule.id}).")
except Exception as e:
print(e)

Expand All @@ -71,7 +71,7 @@ def main():
)
try:
daily_schedule = server.schedules.create(daily_schedule)
print("Daily schedule created (ID: {}).".format(daily_schedule.id))
print(f"Daily schedule created (ID: {daily_schedule.id}).")
except Exception as e:
print(e)

Expand All @@ -89,7 +89,7 @@ def main():
)
try:
weekly_schedule = server.schedules.create(weekly_schedule)
print("Weekly schedule created (ID: {}).".format(weekly_schedule.id))
print(f"Weekly schedule created (ID: {weekly_schedule.id}).")
except Exception as e:
print(e)
options = TSC.RequestOptions()
Expand All @@ -112,7 +112,7 @@ def main():
)
try:
monthly_schedule = server.schedules.create(monthly_schedule)
print("Monthly schedule created (ID: {}).".format(monthly_schedule.id))
print(f"Monthly schedule created (ID: {monthly_schedule.id}).")
except Exception as e:
print(e)

Expand Down
17 changes: 6 additions & 11 deletions samples/explore_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def main():
new_datasource = server.datasources.publish(
new_datasource, args.publish, TSC.Server.PublishMode.Overwrite
)
print("Datasource published. ID: {}".format(new_datasource.id))
print(f"Datasource published. ID: {new_datasource.id}")
else:
print("Publish failed. Could not find the default project.")

# Gets all datasource items
all_datasources, pagination_item = server.datasources.get()
print("\nThere are {} datasources on site: ".format(pagination_item.total_available))
print(f"\nThere are {pagination_item.total_available} datasources on site: ")
print([datasource.name for datasource in all_datasources])

if all_datasources:
Expand All @@ -69,20 +69,15 @@ def main():

# Populate connections
server.datasources.populate_connections(sample_datasource)
print("\nConnections for {}: ".format(sample_datasource.name))
print(
[
"{0}({1})".format(connection.id, connection.datasource_name)
for connection in sample_datasource.connections
]
)
print(f"\nConnections for {sample_datasource.name}: ")
print([f"{connection.id}({connection.datasource_name})" for connection in sample_datasource.connections])

# Add some tags to the datasource
original_tag_set = set(sample_datasource.tags)
sample_datasource.tags.update("a", "b", "c", "d")
server.datasources.update(sample_datasource)
print("\nOld tag set: {}".format(original_tag_set))
print("New tag set: {}".format(sample_datasource.tags))
print(f"\nOld tag set: {original_tag_set}")
print(f"New tag set: {sample_datasource.tags}")

# Delete all tags that were added by setting tags to original
sample_datasource.tags = original_tag_set
Expand Down
10 changes: 4 additions & 6 deletions samples/explore_favorites.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def main():
# get all favorites on site for the logged on user
user: TSC.UserItem = TSC.UserItem()
user.id = server.user_id
print("Favorites for user: {}".format(user.id))
print(f"Favorites for user: {user.id}")
server.favorites.get(user)
print(user.favorites)

Expand All @@ -57,7 +57,7 @@ def main():
if views is not None and len(views) > 0:
my_view = views[0]
server.favorites.add_favorite_view(user, my_view)
print("View added to favorites. View Name: {}, View ID: {}".format(my_view.name, my_view.id))
print(f"View added to favorites. View Name: {my_view.name}, View ID: {my_view.id}")

all_datasource_items, pagination_item = server.datasources.get()
if all_datasource_items:
Expand All @@ -70,12 +70,10 @@ def main():
)

server.favorites.delete_favorite_workbook(user, my_workbook)
print(
"Workbook deleted from favorites. Workbook Name: {}, Workbook ID: {}".format(my_workbook.name, my_workbook.id)
)
print(f"Workbook deleted from favorites. Workbook Name: {my_workbook.name}, Workbook ID: {my_workbook.id}")

server.favorites.delete_favorite_view(user, my_view)
print("View deleted from favorites. View Name: {}, View ID: {}".format(my_view.name, my_view.id))
print(f"View deleted from favorites. View Name: {my_view.name}, View ID: {my_view.id}")

server.favorites.delete_favorite_datasource(user, my_datasource)
print(
Expand Down
2 changes: 1 addition & 1 deletion samples/explore_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main():

if args.delete:
print("You can only delete the site you are currently in")
print("Delete site `{}`?".format(current_site.name))
print(f"Delete site `{current_site.name}`?")
# server.sites.delete(server.site_id)

elif args.create:
Expand Down
4 changes: 2 additions & 2 deletions samples/explore_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def main():
new_webhook.event = "datasource-created"
print(new_webhook)
new_webhook = server.webhooks.create(new_webhook)
print("Webhook created. ID: {}".format(new_webhook.id))
print(f"Webhook created. ID: {new_webhook.id}")

# Gets all webhook items
all_webhooks, pagination_item = server.webhooks.get()
print("\nThere are {} webhooks on site: ".format(pagination_item.total_available))
print(f"\nThere are {pagination_item.total_available} webhooks on site: ")
print([webhook.name for webhook in all_webhooks])

if all_webhooks:
Expand Down
33 changes: 14 additions & 19 deletions samples/explore_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def main():
if default_project is not None:
new_workbook = TSC.WorkbookItem(default_project.id)
new_workbook = server.workbooks.publish(new_workbook, args.publish, overwrite_true)
print("Workbook published. ID: {}".format(new_workbook.id))
print(f"Workbook published. ID: {new_workbook.id}")
else:
print("Publish failed. Could not find the default project.")

# Gets all workbook items
all_workbooks, pagination_item = server.workbooks.get()
print("\nThere are {} workbooks on site: ".format(pagination_item.total_available))
print(f"\nThere are {pagination_item.total_available} workbooks on site: ")
print([workbook.name for workbook in all_workbooks])

if all_workbooks:
Expand All @@ -78,27 +78,22 @@ def main():

# Populate views
server.workbooks.populate_views(sample_workbook)
print("\nName of views in {}: ".format(sample_workbook.name))
print(f"\nName of views in {sample_workbook.name}: ")
print([view.name for view in sample_workbook.views])

# Populate connections
server.workbooks.populate_connections(sample_workbook)
print("\nConnections for {}: ".format(sample_workbook.name))
print(
[
"{0}({1})".format(connection.id, connection.datasource_name)
for connection in sample_workbook.connections
]
)
print(f"\nConnections for {sample_workbook.name}: ")
print([f"{connection.id}({connection.datasource_name})" for connection in sample_workbook.connections])

# Update tags and show_tabs flag
original_tag_set = set(sample_workbook.tags)
sample_workbook.tags.update("a", "b", "c", "d")
sample_workbook.show_tabs = True
server.workbooks.update(sample_workbook)
print("\nWorkbook's old tag set: {}".format(original_tag_set))
print("Workbook's new tag set: {}".format(sample_workbook.tags))
print("Workbook tabbed: {}".format(sample_workbook.show_tabs))
print(f"\nWorkbook's old tag set: {original_tag_set}")
print(f"Workbook's new tag set: {sample_workbook.tags}")
print(f"Workbook tabbed: {sample_workbook.show_tabs}")

# Delete all tags that were added by setting tags to original
sample_workbook.tags = original_tag_set
Expand All @@ -109,8 +104,8 @@ def main():
original_tag_set = set(sample_view.tags)
sample_view.tags.add("view_tag")
server.views.update(sample_view)
print("\nView's old tag set: {}".format(original_tag_set))
print("View's new tag set: {}".format(sample_view.tags))
print(f"\nView's old tag set: {original_tag_set}")
print(f"View's new tag set: {sample_view.tags}")

# Delete tag from just one view
sample_view.tags = original_tag_set
Expand All @@ -119,14 +114,14 @@ def main():
if args.download:
# Download
path = server.workbooks.download(sample_workbook.id, args.download)
print("\nDownloaded workbook to {}".format(path))
print(f"\nDownloaded workbook to {path}")

if args.preview_image:
# Populate workbook preview image
server.workbooks.populate_preview_image(sample_workbook)
with open(args.preview_image, "wb") as f:
f.write(sample_workbook.preview_image)
print("\nDownloaded preview image of workbook to {}".format(os.path.abspath(args.preview_image)))
print(f"\nDownloaded preview image of workbook to {os.path.abspath(args.preview_image)}")

# get custom views
cvs, _ = server.custom_views.get()
Expand All @@ -153,10 +148,10 @@ def main():
server.workbooks.populate_powerpoint(sample_workbook)
with open(args.powerpoint, "wb") as f:
f.write(sample_workbook.powerpoint)
print("\nDownloaded powerpoint of workbook to {}".format(os.path.abspath(args.powerpoint)))
print(f"\nDownloaded powerpoint of workbook to {os.path.abspath(args.powerpoint)}")

if args.delete:
print("deleting {}".format(c.id))
print(f"deleting {c.id}")
unlucky = TSC.CustomViewItem(c.id)
server.custom_views.delete(unlucky.id)

Expand Down
6 changes: 3 additions & 3 deletions samples/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def main():
item = server.views.get_by_id(args.resource_id)

if not item:
print("No item found for id {}".format(args.resource_id))
print(f"No item found for id {args.resource_id}")
exit(1)

print("Item found: {}".format(item.name))
print(f"Item found: {item.name}")
# We have a number of different types and functions for each different export type.
# We encode that information above in the const=(...) parameter to the add_argument function to make
# the code automatically adapt for the type of export the user is doing.
B41A Expand All @@ -83,7 +83,7 @@ def main():
if args.file:
filename = args.file
else:
filename = "out.{}".format(extension)
filename = f"out.{extension}"

populate(item, options)
with open(filename, "wb") as f:
Expand Down
2 changes: 1 addition & 1 deletion samples/extracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
with server.auth.sign_in(tableau_auth):
# Gets all workbook items
all_workbooks, pagination_item = server.workbooks.get()
print("\nThere are {} workbooks on site: ".format(pagination_item.total_available))
print(f"\nThere are {pagination_item.total_available} workbooks on site: ")
print([workbook.name for workbook in all_workbooks])

if all_workbooks:
Expand Down
2 changes: 1 addition & 1 deletion samples/filter_sort_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def main():
group_name = filtered_groups.pop().name
print(group_name)
else:
error = "No project named '{}' found".format(filter_group_name)
error = f"No project named '{filter_group_name}' found"
print(error)

# Or, try the above with the django style filtering
Expand Down
2 changes: 1 addition & 1 deletion samples/filter_sort_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main():
project_name = filtered_projects.pop().name
print(project_name)
else:
error = "No project named '{}' found".format(filter_project_name)
error = f"No project named '{filter_project_name}' found"
print(error)

create_example_project(name="Example 1", server=server)
Expand Down
4 changes: 2 additions & 2 deletions samples/getting_started/1_hello_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def main():
# This is the domain for Tableau's Developer Program
server_url = "https://10ax.online.tableau.com"
server = TSC.Server(server_url)
print("Connected to {}".format(server.server_info.baseurl))
print("Server information: {}".format(server.server_info))
print(f"Connected to {server.server_info.baseurl}")
print(f"Server information: {server.server_info}")
print("Sign up for a test site at https://www.tableau.com/developer")


Expand Down
Loading
Loading
0