Skip to content

Commit

Permalink
⬆️ Allow more recent version of packaging (#1196)
Browse files Browse the repository at this point in the history
re-format to match new black standards
  • Loading branch information
r-richmond committed Feb 21, 2023
1 parent 514cc13 commit ccdd790
Show file tree
Hide file tree
Showing 36 changed files with 1 addition and 53 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"

dependencies = [
'defusedxml>=0.7.1',
'packaging~=21.3',
'packaging>=22.0', # bumping to minimum version required by black
'requests>=2.28',
'urllib3~=1.26.8',
]
Expand Down
1 change: 0 additions & 1 deletion samples/add_default_permission.py
Expand Up @@ -46,7 +46,6 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

# Create a sample project
project = TSC.ProjectItem("sample_project")
project = server.projects.create(project)
Expand Down
1 change: 0 additions & 1 deletion samples/create_group.py
Expand Up @@ -18,7 +18,6 @@


def main():

parser = argparse.ArgumentParser(description="Creates a sample user group.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down
1 change: 0 additions & 1 deletion samples/create_schedules.py
Expand Up @@ -15,7 +15,6 @@


def main():

parser = argparse.ArgumentParser(description="Creates sample schedules for each type of frequency.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down
1 change: 0 additions & 1 deletion samples/explore_datasource.py
Expand Up @@ -16,7 +16,6 @@


def main():

parser = argparse.ArgumentParser(description="Explore datasource functions supported by the Server API.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down
1 change: 0 additions & 1 deletion samples/explore_site.py
Expand Up @@ -12,7 +12,6 @@


def main():

parser = argparse.ArgumentParser(description="Explore site updates by the Server API.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down
3 changes: 0 additions & 3 deletions samples/explore_webhooks.py
Expand Up @@ -17,7 +17,6 @@


def main():

parser = argparse.ArgumentParser(description="Explore webhook functions supported by the Server API.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down Expand Up @@ -49,10 +48,8 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

# Create webhook if create flag is set (-create, -c)
if args.create:

new_webhook = TSC.WebhookItem()
new_webhook.name = args.create
new_webhook.url = "https://ifttt.com/maker-url"
Expand Down
2 changes: 0 additions & 2 deletions samples/explore_workbook.py
Expand Up @@ -17,7 +17,6 @@


def main():

parser = argparse.ArgumentParser(description="Explore workbook functions supported by the Server API.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down Expand Up @@ -52,7 +51,6 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

# Publish workbook if publish flag is set (-publish, -p)
overwrite_true = TSC.Server.PublishMode.Overwrite
if args.publish:
Expand Down
2 changes: 0 additions & 2 deletions samples/extracts.py
Expand Up @@ -17,7 +17,6 @@


def main():

parser = argparse.ArgumentParser(description="Explore extract functions supported by the Server API.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down Expand Up @@ -50,7 +49,6 @@ def main():
server.add_http_options({"verify": False})
server.use_server_version()
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))
Expand Down
1 change: 0 additions & 1 deletion samples/filter_sort_groups.py
Expand Up @@ -53,7 +53,6 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

group_name = "SALES NORTHWEST"
# Try to create a group named "SALES NORTHWEST"
create_example_group(group_name, server)
Expand Down
1 change: 0 additions & 1 deletion samples/filter_sort_projects.py
Expand Up @@ -18,7 +18,6 @@ def create_example_project(
description="Project created for testing",
server=None,
):

new_project = TSC.ProjectItem(name=name, content_permissions=content_permissions, description=description)
try:
server.projects.create(new_project)
Expand Down
2 changes: 0 additions & 2 deletions samples/initialize_server.py
Expand Up @@ -45,7 +45,6 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

################################################################################
# Step 2: Create the site we need only if it doesn't exist
################################################################################
Expand Down Expand Up @@ -75,7 +74,6 @@ def main():
tableau_auth.site_id = args.site_id

with server_upload.auth.sign_in(tableau_auth):

################################################################################
# Step 4: Create the project we need only if it doesn't exist
################################################################################
Expand Down
1 change: 0 additions & 1 deletion samples/login.py
Expand Up @@ -48,7 +48,6 @@ def sample_define_common_options(parser):


def sample_connect_to_server(args):

if args.username:
# Trying to authenticate using username and password.
password = args.password or getpass.getpass("Password: ")
Expand Down
1 change: 0 additions & 1 deletion samples/move_workbook_projects.py
Expand Up @@ -15,7 +15,6 @@


def main():

parser = argparse.ArgumentParser(description="Move one workbook from the default project to another.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down
2 changes: 0 additions & 2 deletions samples/move_workbook_sites.py
Expand Up @@ -16,7 +16,6 @@


def main():

parser = argparse.ArgumentParser(
description="Move one workbook from the"
"default project of the default site to"
Expand Down Expand Up @@ -84,7 +83,6 @@ def main():
# Signing into another site requires another server object
# because of the different auth token and site ID.
with dest_server.auth.sign_in(tableau_auth):

# Step 5: Create a new workbook item and publish workbook. Note that
# an empty project_id will publish to the 'Default' project.
new_workbook = TSC.WorkbookItem(name=args.workbook_name, project_id="")
Expand Down
1 change: 0 additions & 1 deletion samples/pagination_sample.py
Expand Up @@ -18,7 +18,6 @@


def main():

parser = argparse.ArgumentParser(description="Demonstrate pagination on the list of workbooks on the server.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down
2 changes: 0 additions & 2 deletions samples/publish_workbook.py
Expand Up @@ -22,7 +22,6 @@


def main():

parser = argparse.ArgumentParser(description="Publish a workbook to server.")
# Common options; please keep those in sync across all samples
parser.add_argument("--server", "-s", required=True, help="server address")
Expand Down Expand Up @@ -55,7 +54,6 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

# Step 2: Get all the projects on server, then look for the default one.
all_projects, pagination_item = server.projects.get()
default_project = next((project for project in all_projects if project.is_default()), None)
Expand Down
1 change: 0 additions & 1 deletion samples/query_permissions.py
Expand Up @@ -44,7 +44,6 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):

# Mapping to grab the handler for the user-inputted resource type
endpoint = {
"workbook": server.workbooks,
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/models/connection_item.py
Expand Up @@ -85,7 +85,6 @@ def from_xml_element(cls, parsed_response, ns) -> List["ConnectionItem"]:
connection_credentials = connection_xml.find(".//t:connectionCredentials", namespaces=ns)

if connection_credentials is not None:

connection_item.connection_credentials = ConnectionCredentials.from_xml_element(
connection_credentials, ns
)
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/models/group_item.py
Expand Up @@ -12,7 +12,6 @@


class GroupItem(object):

tag_name: str = "group"

class LicenseMode:
Expand Down
2 changes: 0 additions & 2 deletions tableauserverclient/models/interval_item.py
Expand Up @@ -27,7 +27,6 @@ class Day:

class HourlyInterval(object):
def __init__(self, start_time, end_time, interval_value):

self.start_time = start_time
self.end_time = end_time
self.interval = interval_value
Expand Down Expand Up @@ -70,7 +69,6 @@ def interval(self, interval):
self._interval = interval

def _interval_type_pairs(self):

# We use fractional hours for the two minute-based intervals.
# Need to convert to minutes from hours here
if self.interval in {0.25, 0.5}:
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/models/property_decorators.py
Expand Up @@ -101,7 +101,6 @@ def wrapper(self, value):


def property_matches(regex_to_match, error):

compiled_re = re.compile(regex_to_match)

def wrapper(func):
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/models/table_item.py
Expand Up @@ -140,7 +140,6 @@ def from_response(cls, resp, ns):

@staticmethod
def _parse_element(table_xml, ns):

table_values = table_xml.attrib.copy()

contact = table_xml.find(".//t:contact", namespaces=ns)
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/models/user_item.py
Expand Up @@ -21,7 +21,6 @@


class UserItem(object):

tag_name: str = "user"

class Roles:
Expand Down
Expand Up @@ -199,7 +199,6 @@ def publish(
connections: Optional[Sequence[ConnectionItem]] = None,
as_job: bool = False,
) -> Union[DatasourceItem, JobItem]:

if isinstance(file, (os.PathLike, str)):
if not os.path.isfile(file):
error = "File path does not lead to an existing file."
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/server/endpoint/schedules_endpoint.py
Expand Up @@ -90,7 +90,6 @@ def add_to_schedule(
flow: Optional["FlowItem"] = None,
task_type: Optional[str] = None,
) -> List[AddResponse]:

# There doesn't seem to be a good reason to allow one item of each type?
if workbook and datasource:
warnings.warn("Passing in multiple items for add_to_schedule will be deprecated", PendingDeprecationWarning)
Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/server/endpoint/workbooks_endpoint.py
Expand Up @@ -319,7 +319,6 @@ def publish(
hidden_views: Optional[Sequence[str]] = None,
skip_connection_check: bool = False,
):

if connection_credentials is not None:
import warnings

Expand Down
1 change: 0 additions & 1 deletion tableauserverclient/server/pager.py
Expand Up @@ -13,7 +13,6 @@ class Pager(object):
"""

def __init__(self, endpoint, request_opts=None, **kwargs):

if hasattr(endpoint, "get"):
# The simpliest case is to take an Endpoint and call its get
endpoint = partial(endpoint.get, **kwargs)
Expand Down
1 change: 0 additions & 1 deletion test/test_datasource.py
Expand Up @@ -542,7 +542,6 @@ def test_publish_hyper_file_object_raises_exception(self) -> None:
)

def test_publish_tde_file_object_raises_exception(self) -> None:

new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "test")
tds_asset = asset(os.path.join("Data", "Tableau Samples", "World Indicators.tde"))
with open(tds_asset, "rb") as file_object:
Expand Down
1 change: 0 additions & 1 deletion test/test_endpoint.py
Expand Up @@ -29,7 +29,6 @@ def test_get_request_stream(self) -> None:

def test_binary_log_truncated(self):
class FakeResponse(object):

headers = {"Content-Type": "application/octet-stream"}
content = b"\x1337" * 1000
status_code = 200
Expand Down
6 changes: 0 additions & 6 deletions test/test_filesys_helpers.py
Expand Up @@ -10,7 +10,6 @@

class FilesysTests(unittest.TestCase):
def test_get_file_size_returns_correct_size(self):

target_size = 1000 # bytes

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

def test_get_file_size_returns_zero_for_empty_file(self):

with BytesIO() as f:
file_size = get_file_object_size(f)

self.assertEqual(file_size, 0)

def test_get_file_size_coincides_with_built_in_method(self):

asset_path = asset("SampleWB.twbx")
target_size = os.path.getsize(asset_path)
with open(asset_path, "rb") as f:
Expand All @@ -37,7 +34,6 @@ def test_get_file_size_coincides_with_built_in_method(self):
self.assertEqual(file_size, target_size)

def test_get_file_type_identifies_a_zip_file(self):

with BytesIO() as file_object:
with ZipFile(file_object, "w") as zf:
with BytesIO() as stream:
Expand All @@ -59,7 +55,6 @@ def test_get_file_type_identifies_twbx_as_zip_file(self):
self.assertEqual(file_type, "zip")

def test_get_file_type_identifies_xml_file(self):

root = ET.Element("root")
child = ET.SubElement(root, "child")
child.text = "This is a child element"
Expand Down Expand Up @@ -95,7 +90,6 @@ def test_get_file_type_identifies_tde_file(self):
self.assertEqual(file_type, "tde")

def test_get_file_type_handles_unknown_file_type(self):

# Create a dummy png file
with BytesIO() as file_object:
png_signature = bytes.fromhex("89504E470D0A1A0A")
Expand Down
1 change: 0 additions & 1 deletion test/test_flow.py
Expand Up @@ -174,7 +174,6 @@ def test_publish_file_object(self) -> None:
publish_mode = self.server.PublishMode.CreateNew

with open(sample_flow, "rb") as fp:

publish_mode = self.server.PublishMode.CreateNew

new_flow = self.server.flows.publish(new_flow, fp, publish_mode)
Expand Down
1 change: 0 additions & 1 deletion test/test_project.py
Expand Up @@ -139,7 +139,6 @@ def test_update_missing_id(self) -> None:
self.assertRaises(TSC.MissingRequiredFieldError, self.server.projects.update, single_project)

def test_create(self) -> None:

with open(CREATE_XML, "rb") as f:
response_xml = f.read().decode("utf-8")
with requests_mock.mock() as m:
Expand Down
1 change: 0 additions & 1 deletion test/test_site_model.py
Expand Up @@ -22,7 +22,6 @@ def test_invalid_admin_mode(self):
site.admin_mode = "Hello"

def test_invalid_content_url(self):

with self.assertRaises(ValueError):
site = TSC.SiteItem(name="蚵仔煎", content_url="蚵仔煎")

Expand Down
1 change: 0 additions & 1 deletion test/test_user_model.py
Expand Up @@ -32,7 +32,6 @@ def test_invalid_site_role(self):


class UserDataTest(unittest.TestCase):

logger = logging.getLogger("UserDataTest")

role_inputs = [
Expand Down

0 comments on commit ccdd790

Please sign in to comment.