Skip to content

Commit 415cf21

Browse files
jacalataclaude
andcommitted
Address review feedback on public type aliases
- Delete duplicate FilePath/FileObjectW/PathOrFileW in endpoint.py; import from tableauserverclient.types (the whole point of the consolidation) - Remove FileObject, PathOrFile, IDPAttributes, IDPProperty from __all__: FileObject/PathOrFile are wider than any runtime path accepts; the two Protocol classes are structural-only and users get HasIdpConfigurationID as the caller-facing type - Add CHANGELOG entry for the newly-stable public typing surface - Add smoke test guarding the top-level exports and AddResponse._fields Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0881adb commit 415cf21

4 files changed

Lines changed: 33 additions & 12 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
hierarchy path (e.g. `"Marketing/Q1 Reports"`). The walk is performed level by
66
level using the REST API name filter, so a path with *n* components issues *n*
77
requests. Returns the matching `ProjectItem` or `None` if no project is found.
8+
* Consolidated public typing surface under `tableauserverclient.types` and
9+
exported it at the top level. The following names are now stable public API
10+
for downstream type checkers: `HyperAction`, `HyperActionCondition`,
11+
`HyperActionRow`, `HyperActionTable`, `FilePath`, `FileObjectR`,
12+
`FileObjectW`, `PathOrFileR`, `PathOrFileW`, `AddResponse`,
13+
`HasIdpConfigurationID`.
814

915
## 0.18.0 (6 April 2022)
1016
* Switched to using defused_xml for xml attack protection

‎tableauserverclient/__init__.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@
6161
from tableauserverclient.types import (
6262
AddResponse,
6363
FilePath,
64-
FileObject,
6564
FileObjectR,
6665
FileObjectW,
6766
HasIdpConfigurationID,
6867
HyperAction,
6968
HyperActionCondition,
7069
HyperActionRow,
7170
HyperActionTable,
72-
IDPAttributes,
73-
IDPProperty,
74-
PathOrFile,
7571
PathOrFileR,
7672
PathOrFileW,
7773
)
@@ -116,7 +112,6 @@
116112
"FavoriteItem",
117113
"FileuploadItem",
118114
"FilePath",
119-
"FileObject",
120115
"FileObjectR",
121116
"FileObjectW",
122117
"Filter",
@@ -131,8 +126,6 @@
131126
"HyperActionCondition",
132127
"HyperActionRow",
133128
"HyperActionTable",
134-
"IDPAttributes",
135-
"IDPProperty",
136129
"ImageRequestOptions",
137130
"IntervalItem",
138131
"JobItem",
@@ -152,7 +145,6 @@
152145
"Permission",
153146
"PermissionsRule",
154147
"PersonalAccessTokenAuth",
155-
"PathOrFile",
156148
"PathOrFileR",
157149
"PathOrFileW",
158150
"ProjectItem",

‎tableauserverclient/server/endpoint/endpoint.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from tableauserverclient import helpers, get_versions
3838

3939
from tableauserverclient.helpers.logging import logger
40+
from tableauserverclient.types import PathOrFileW
4041

4142
if TYPE_CHECKING:
4243
from tableauserverclient.server.server import Server
@@ -330,10 +331,6 @@ def wrapper(self: E, *args: P.args, **kwargs: P.kwargs) -> R:
330331

331332
_io_types_w = (io.BytesIO, io.BufferedWriter)
332333

333-
FilePath = str | os.PathLike
334-
FileObjectW = io.BufferedWriter | io.BytesIO
335-
PathOrFileW = FilePath | FileObjectW
336-
337334

338335
class DownloadableMixin:
339336
"""Mixin for endpoints whose resources can be downloaded as binary files.

‎test/test_types_exports.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Guard that types.py public exports don't silently regress."""
2+
3+
import tableauserverclient as TSC
4+
5+
6+
def test_types_are_top_level_importable():
7+
for name in (
8+
"HyperAction",
9+
"HyperActionCondition",
10+
"HyperActionRow",
11+
"HyperActionTable",
12+
"FilePath",
13+
"FileObjectR",
14+
"FileObjectW",
15+
"PathOrFileR",
16+
"PathOrFileW",
17+
"AddResponse",
18+
"HasIdpConfigurationID",
19+
):
20+
assert hasattr(TSC, name), f"missing {name}"
21+
assert name in TSC.__all__, f"{name} not in __all__"
22+
23+
24+
def test_add_response_shape():
25+
# namedtuple contract that samples/users depend on
26+
assert TSC.AddResponse._fields == ("result", "error", "warnings", "task_created")

0 commit comments

Comments
 (0)