Skip to content

Commit 26bcfbb

Browse files
committed
Inline DEFAULT_NAMESPACE literal to avoid top-level server.py import
Cosmetic import-graph cleanup on top of #1863's move of `NAMESPACE` from `namespace.py` into `server/server.py`. Before this change, `tableauserverclient/__init__.py:2` did `from tableauserverclient. server.server import NAMESPACE`, which forces `server.server` (and its transitive endpoint tree) to load just to read a string constant. Copilot flagged the circular-import path this creates: `server. server` -> `server.endpoint.endpoint` -> `from tableauserverclient import ...` -> `__init__` -> `server.server`. Python resolves the chain today because the reentrant lookups pull submodules whose own load doesn't back-reference the partially-initialized parent, but the shape is fragile and adding a new top-level import to `__init__.py` before line 2 could easily break it. Replaced the import with the string literal. Kept in sync with the `NAMESPACE` constant in `server/server.py`. Also removes one of the two entry points into `server.server` at package load, though everything else in `__init__.py` still transitively pulls the endpoint tree via the models block below, so no real startup savings -- this is defensive, not a perf fix.
1 parent eafeece commit 26bcfbb

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tableauserverclient/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from tableauserverclient.bin._version import get_versions
2-
from tableauserverclient.server.server import NAMESPACE as DEFAULT_NAMESPACE
2+
3+
# Inlined as a string literal (rather than imported from server.server) so
4+
# loading `tableauserverclient` doesn't force the full server + endpoint
5+
# import graph to load just to read a constant. Kept in sync with the
6+
# NAMESPACE constant defined in tableauserverclient/server/server.py.
7+
DEFAULT_NAMESPACE = "http://tableau.com/api"
8+
39
from tableauserverclient.models import (
410
BackgroundJobItem,
511
CollectionItem,

0 commit comments

Comments
 (0)