Skip to content
Open
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
58 changes: 29 additions & 29 deletions tableauserverclient/bin/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import re
import subprocess
import sys
from typing import Any, Callable, Dict, List, Optional, Tuple
from typing import Any, Callable
import functools


def get_keywords() -> Dict[str, str]:
def get_keywords() -> dict[str, str]:
"""Get the keywords needed to look up the version information."""
# these strings will be replaced by git during git-archive.
# setup.py/versioneer.py will grep for the variable names, so they must
Expand Down Expand Up @@ -61,8 +61,8 @@ class NotThisMethod(Exception):
"""Exception raised if a method is not valid for the current scenario."""


LONG_VERSION_PY: Dict[str, str] = {}
HANDLERS: Dict[str, Dict[str, Callable]] = {}
LONG_VERSION_PY: dict[str, str] = {}
HANDLERS: dict[str, dict[str, Callable]] = {}


def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator
Expand All @@ -77,18 +77,18 @@ def decorate(f: Callable) -> Callable:


def run_command(
commands: List[str],
args: List[str],
cwd: Optional[str] = None,
commands: list[str],
args: list[str],
cwd: str | None = None,
verbose: bool = False,
hide_stderr: bool = False,
env: Optional[Dict[str, str]] = None,
) -> Tuple[Optional[str], Optional[int]]:
env: dict[str, str] | None = None,
) -> tuple[str | None, int | None]:
"""Call the given command(s)."""
assert isinstance(commands, list)
process = None

popen_kwargs: Dict[str, Any] = {}
popen_kwargs: dict[str, Any] = {}
if sys.platform == "win32":
# This hides the console window if pythonw.exe is used
startupinfo = subprocess.STARTUPINFO()
Expand Down Expand Up @@ -128,7 +128,7 @@ def versions_from_parentdir(
parentdir_prefix: str,
root: str,
verbose: bool,
) -> Dict[str, Any]:
) -> dict[str, Any]:
"""Try to determine the version from the parent directory name.

Source tarballs conventionally unpack into a directory that includes both
Expand All @@ -153,13 +153,13 @@ def versions_from_parentdir(


@register_vcs_handler("git", "get_keywords")
def git_get_keywords(versionfile_abs: str) -> Dict[str, str]:
def git_get_keywords(versionfile_abs: str) -> dict[str, str]:
"""Extract version information from the given file."""
# the code embedded in _version.py can just fetch the value of these
# keywords. When used from setup.py, we don't want to import _version.py,
# so we do it with a regexp instead. This function is not used from
# _version.py.
keywords: Dict[str, str] = {}
keywords: dict[str, str] = {}
try:
with open(versionfile_abs, "r") as fobj:
for line in fobj:
Expand All @@ -182,10 +182,10 @@ def git_get_keywords(versionfile_abs: str) -> Dict[str, str]:

@register_vcs_handler("git", "keywords")
def git_versions_from_keywords(
keywords: Dict[str, str],
keywords: dict[str, str],
tag_prefix: str,
verbose: bool,
) -> Dict[str, Any]:
) -> dict[str, Any]:
"""Get version information from git keywords."""
if "refnames" not in keywords:
raise NotThisMethod("Short version file found")
Expand Down Expand Up @@ -254,7 +254,7 @@ def git_pieces_from_vcs(
root: str,
verbose: bool,
runner: Callable = run_command
) -> Dict[str, Any]:
) -> dict[str, Any]:
"""Get version from 'git describe' in the root of the source tree.

This only gets called if the git-archive 'subst' keywords were *not*
Expand Down Expand Up @@ -294,7 +294,7 @@ def git_pieces_from_vcs(
raise NotThisMethod("'git rev-parse' failed")
full_out = full_out.strip()

pieces: Dict[str, Any] = {}
pieces: dict[str, Any] = {}
pieces["long"] = full_out
pieces["short"] = full_out[:7] # maybe improved later
pieces["error"] = None
Expand Down Expand Up @@ -386,14 +386,14 @@ def git_pieces_from_vcs(
return pieces


def plus_or_dot(pieces: Dict[str, Any]) -> str:
def plus_or_dot(pieces: dict[str, Any]) -> str:
"""Return a + if we don't already have one, else return a ."""
if "+" in pieces.get("closest-tag", ""):
return "."
return "+"


def render_pep440(pieces: Dict[str, Any]) -> str:
def render_pep440(pieces: dict[str, Any]) -> str:
"""Build up version string, with post-release "local version identifier".

Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
Expand All @@ -418,7 +418,7 @@ def render_pep440(pieces: Dict[str, Any]) -> str:
return rendered


def render_pep440_branch(pieces: Dict[str, Any]) -> str:
def render_pep440_branch(pieces: dict[str, Any]) -> str:
"""TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .

The ".dev0" means not master branch. Note that .dev0 sorts backwards
Expand Down Expand Up @@ -448,7 +448,7 @@ def render_pep440_branch(pieces: Dict[str, Any]) -> str:
return rendered


def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]:
def pep440_split_post(ver: str) -> tuple[str, int | None]:
"""Split pep440 version string at the post-release segment.

Returns the release segments before the post-release and the
Expand All @@ -458,7 +458,7 @@ def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]:
return vc[0], int(vc[1] or 0) if len(vc) == 2 else None


def render_pep440_pre(pieces: Dict[str, Any]) -> str:
def render_pep440_pre(pieces: dict[str, Any]) -> str:
"""TAG[.postN.devDISTANCE] -- No -dirty.

Exceptions:
Expand All @@ -482,7 +482,7 @@ def render_pep440_pre(pieces: Dict[str, Any]) -> str:
return rendered


def render_pep440_post(pieces: Dict[str, Any]) -> str:
def render_pep440_post(pieces: dict[str, Any]) -> str:
"""TAG[.postDISTANCE[.dev0]+gHEX] .

The ".dev0" means dirty. Note that .dev0 sorts backwards
Expand All @@ -509,7 +509,7 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str:
return rendered


def render_pep440_post_branch(pieces: Dict[str, Any]) -> str:
def render_pep440_post_branch(pieces: dict[str, Any]) -> str:
"""TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .

The ".dev0" means not master branch.
Expand Down Expand Up @@ -538,7 +538,7 @@ def render_pep440_post_branch(pieces: Dict[str, Any]) -> str:
return rendered


def render_pep440_old(pieces: Dict[str, Any]) -> str:
def render_pep440_old(pieces: dict[str, Any]) -> str:
"""TAG[.postDISTANCE[.dev0]] .

The ".dev0" means dirty.
Expand All @@ -560,7 +560,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str:
return rendered


def render_git_describe(pieces: Dict[str, Any]) -> str:
def render_git_describe(pieces: dict[str, Any]) -> str:
"""TAG[-DISTANCE-gHEX][-dirty].

Like 'git describe --tags --dirty --always'.
Expand All @@ -580,7 +580,7 @@ def render_git_describe(pieces: Dict[str, Any]) -> str:
return rendered


def render_git_describe_long(pieces: Dict[str, Any]) -> str:
def render_git_describe_long(pieces: dict[str, Any]) -> str:
"""TAG-DISTANCE-gHEX[-dirty].

Like 'git describe --tags --dirty --always -long'.
Expand All @@ -600,7 +600,7 @@ def render_git_describe_long(pieces: Dict[str, Any]) -> str:
return rendered


def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]:
def render(pieces: dict[str, Any], style: str) -> dict[str, Any]:
"""Render the given version pieces into the requested style."""
if pieces["error"]:
return {"version": "unknown",
Expand Down Expand Up @@ -636,7 +636,7 @@ def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]:
"date": pieces.get("date")}


def get_versions() -> Dict[str, Any]:
def get_versions() -> dict[str, Any]:
"""Get version information or return default if unable to do so."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
Expand Down
19 changes: 9 additions & 10 deletions tableauserverclient/models/collection_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime
from typing import Optional
from xml.etree.ElementTree import Element

from defusedxml.ElementTree import fromstring
Expand All @@ -11,15 +10,15 @@

class CollectionItem:
def __init__(self) -> None:
self.id: Optional[str] = None
self.name: Optional[str] = None
self.description: Optional[str] = None
self.created_at: Optional[datetime] = None
self.updated_at: Optional[datetime] = None
self.owner: Optional[UserItem] = None
self.total_item_count: Optional[int] = None
self.permissioned_item_count: Optional[int] = None
self.visibility: Optional[str] = None # Assuming visibility is a string, adjust as necessary
self.id: str | None = None
self.name: str | None = None
self.description: str | None = None
self.created_at: datetime | None = None
self.updated_at: datetime | None = None
self.owner: UserItem | None = None
self.total_item_count: int | None = None
self.permissioned_item_count: int | None = None
self.visibility: str | None = None # Assuming visibility is a string, adjust as necessary

@classmethod
def from_response(cls, response: bytes, ns) -> list[Self]:
Expand Down
39 changes: 19 additions & 20 deletions tableauserverclient/models/connection_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import Optional

from defusedxml.ElementTree import fromstring

Expand Down Expand Up @@ -51,42 +50,42 @@ class ConnectionItem:
"""

def __init__(self):
self._datasource_id: Optional[str] = None
self._datasource_name: Optional[str] = None
self._id: Optional[str] = None
self._connection_type: Optional[str] = None
self._datasource_id: str | None = None
self._datasource_name: str | None = None
self._id: str | None = None
self._connection_type: str | None = None
self.embed_password: bool = None
self.password: Optional[str] = None
self.server_address: Optional[str] = None
self.server_port: Optional[str] = None
self.username: Optional[str] = None
self.connection_credentials: Optional[ConnectionCredentials] = None
self._query_tagging: Optional[bool] = None
self._auth_type: Optional[str] = None
self.password: str | None = None
self.server_address: str | None = None
self.server_port: str | None = None
self.username: str | None = None
self.connection_credentials: ConnectionCredentials | None = None
self._query_tagging: bool | None = None
self._auth_type: str | None = None

@property
def datasource_id(self) -> Optional[str]:
def datasource_id(self) -> str | None:
return self._datasource_id

@property
def datasource_name(self) -> Optional[str]:
def datasource_name(self) -> str | None:
return self._datasource_name

@property
def id(self) -> Optional[str]:
def id(self) -> str | None:
return self._id

@property
def connection_type(self) -> Optional[str]:
def connection_type(self) -> str | None:
return self._connection_type

@property
def query_tagging(self) -> Optional[bool]:
def query_tagging(self) -> bool | None:
return self._query_tagging

@query_tagging.setter
@property_is_boolean
def query_tagging(self, value: Optional[bool]):
def query_tagging(self, value: bool | None):
# if connection type = hyper, Snowflake, or Teradata, we can't change this value: it is always true
if self._connection_type in ["hyper", "snowflake", "teradata"]:
logger.debug(
Expand All @@ -96,11 +95,11 @@ def query_tagging(self, value: Optional[bool]):
self._query_tagging = value

@property
def auth_type(self) -> Optional[str]:
def auth_type(self) -> str | None:
return self._auth_type

@auth_type.setter
def auth_type(self, value: Optional[str]):
def auth_type(self, value: str | None):
self._auth_type = value

def __repr__(self):
Expand Down
Loading
Loading