Skip to content

Commit 4623ee9

Browse files
Abel Milashclaude
andcommitted
Restore package-level __all__ and add DataverseClient to top-level
Re-exports are now declared in each package's __all__ list: - top-level: DataverseClient, __version__, col, raw, DataverseModel, QueryResult (added DataverseClient; the 4 GA convenience symbols remain) - core: 8 symbols (DataverseConfig, OperationContext, all 5 errors, LogConfig) - models: 24 symbols - operations: 13 symbols Why: analysis of the original 60-warning doc-build report showed warnings were caused by three independent root causes: 1. External pandas refs (~22) - fixed by doc-repo xrefmap_custom.yml 2. Docstring bugs (~17) - fixed by earlier commits qualifying :class: refs 3. Re-export amplification (~21) - doubled the docstring bugs above Now that root causes 1 and 2 are resolved, restoring __all__ no longer amplifies any warnings. The latest docfx report shows 3 warnings (all since fixed) and no duplicate-target warnings. Top-level __init__.py also adds DataverseClient (the primary entry point, matching 'from openai import OpenAI' / 'from anthropic import Anthropic' SDK conventions). Tests updated to assert exact __all__ contents per package (catches accidental drift). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c1fb5e6 commit 4623ee9

5 files changed

Lines changed: 125 additions & 25 deletions

File tree

src/PowerPlatform/Dataverse/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33

44
from importlib.metadata import version
55

6-
from .models.filters import col, raw
7-
from .models.protocol import DataverseModel
8-
from .models.record import QueryResult
9-
6+
# Set __version__ FIRST. Downstream modules (e.g. data/_odata_base.py) import
7+
# this back from the top-level package, so it must be bound before any
8+
# transitive import of those modules runs.
109
__version__ = version("PowerPlatform-Dataverse-Client")
1110

12-
__all__ = ["__version__", "col", "raw", "DataverseModel", "QueryResult"]
11+
from .client import DataverseClient # noqa: E402
12+
from .models.filters import col, raw # noqa: E402
13+
from .models.protocol import DataverseModel # noqa: E402
14+
from .models.record import QueryResult # noqa: E402
15+
16+
__all__ = [
17+
"DataverseClient",
18+
"DataverseModel",
19+
"QueryResult",
20+
"__version__",
21+
"col",
22+
"raw",
23+
]

src/PowerPlatform/Dataverse/core/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,13 @@
1212
from .errors import DataverseError, HttpError, MetadataError, SQLParseError, ValidationError
1313
from .log_config import LogConfig
1414

15-
__all__: list[str] = []
15+
__all__ = [
16+
"DataverseConfig",
17+
"DataverseError",
18+
"HttpError",
19+
"LogConfig",
20+
"MetadataError",
21+
"OperationContext",
22+
"SQLParseError",
23+
"ValidationError",
24+
]

src/PowerPlatform/Dataverse/models/__init__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,29 @@
3434
from .table_info import AlternateKeyInfo, ColumnInfo, TableInfo
3535
from .upsert import UpsertItem
3636

37-
__all__: list[str] = []
37+
__all__ = [
38+
"AlternateKeyInfo",
39+
"BatchItemResponse",
40+
"BatchResult",
41+
"CascadeConfiguration",
42+
"ColumnInfo",
43+
"ColumnProxy",
44+
"DataverseModel",
45+
"ExpandOption",
46+
"FetchXmlQuery",
47+
"FilterExpression",
48+
"Label",
49+
"LocalizedLabel",
50+
"LookupAttributeMetadata",
51+
"ManyToManyRelationshipMetadata",
52+
"OneToManyRelationshipMetadata",
53+
"QueryBuilder",
54+
"QueryParams",
55+
"QueryResult",
56+
"Record",
57+
"RelationshipInfo",
58+
"TableInfo",
59+
"UpsertItem",
60+
"col",
61+
"raw",
62+
]

src/PowerPlatform/Dataverse/operations/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,18 @@
2424
from .records import RecordOperations
2525
from .tables import TableOperations
2626

27-
__all__: list[str] = []
27+
__all__ = [
28+
"BatchDataFrameOperations",
29+
"BatchOperations",
30+
"BatchQueryOperations",
31+
"BatchRecordOperations",
32+
"BatchRequest",
33+
"BatchTableOperations",
34+
"ChangeSet",
35+
"ChangeSetRecordOperations",
36+
"DataFrameOperations",
37+
"FileOperations",
38+
"QueryOperations",
39+
"RecordOperations",
40+
"TableOperations",
41+
]

tests/unit/test_package_exports.py

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4-
"""Tests for package-level imports.
4+
"""Tests for package-level re-exports.
55
6-
The three sub-packages (``core``, ``models``, ``operations``) deliberately keep
7-
``__all__`` empty to avoid creating duplicate doc-tool entries for re-exported
8-
symbols. Symbols are still importable from the package namespace because
9-
Python's ``from package import Symbol`` does not consult ``__all__``.
6+
Each package (``PowerPlatform.Dataverse``, ``core``, ``models``, ``operations``)
7+
re-exports its public symbols and declares them in ``__all__``. This gives users
8+
short, stable import paths (``from PowerPlatform.Dataverse.models import Record``)
9+
that survive internal module reorganization.
1010
1111
These tests verify:
12-
1. ``__all__`` is empty (locks in the design decision).
13-
2. Every expected public symbol is still importable from the package namespace.
14-
3. Each imported symbol is the same object as its source definition.
12+
1. ``__all__`` matches the expected list exactly (catches accidental drift).
13+
2. Every name in ``__all__`` is importable from the package namespace.
14+
3. Each re-export is the same object as its source definition.
1515
"""
1616

1717
import unittest
1818

19+
DATAVERSE_EXPECTED = [
20+
"DataverseClient",
21+
"DataverseModel",
22+
"QueryResult",
23+
"__version__",
24+
"col",
25+
"raw",
26+
]
27+
1928
CORE_EXPECTED = [
2029
"DataverseConfig",
2130
"DataverseError",
@@ -71,14 +80,46 @@
7180
]
7281

7382

83+
class TestDataverseTopLevelExports(unittest.TestCase):
84+
"""Verify top-level PowerPlatform.Dataverse package exports."""
85+
86+
def test_all_matches_expected(self):
87+
"""``__all__`` matches the expected list exactly."""
88+
import PowerPlatform.Dataverse as m
89+
90+
self.assertEqual(sorted(m.__all__), sorted(DATAVERSE_EXPECTED))
91+
92+
def test_expected_symbols_importable(self):
93+
"""Every expected public symbol is reachable from the package namespace."""
94+
import PowerPlatform.Dataverse as m
95+
96+
for name in DATAVERSE_EXPECTED:
97+
self.assertTrue(hasattr(m, name), f"{name!r} not importable from PowerPlatform.Dataverse")
98+
99+
def test_identity(self):
100+
"""Re-exported objects are the same objects as their source definitions."""
101+
import PowerPlatform.Dataverse as m
102+
from PowerPlatform.Dataverse.client import DataverseClient
103+
from PowerPlatform.Dataverse.models.filters import col, raw
104+
from PowerPlatform.Dataverse.models.protocol import DataverseModel
105+
from PowerPlatform.Dataverse.models.record import QueryResult
106+
107+
self.assertIs(m.DataverseClient, DataverseClient)
108+
self.assertIs(m.DataverseModel, DataverseModel)
109+
self.assertIs(m.QueryResult, QueryResult)
110+
self.assertIs(m.col, col)
111+
self.assertIs(m.raw, raw)
112+
self.assertIsInstance(m.__version__, str)
113+
114+
74115
class TestCoreExports(unittest.TestCase):
75116
"""Verify package-level imports for PowerPlatform.Dataverse.core."""
76117

77-
def test_all_is_empty(self):
78-
"""``__all__`` is deliberately empty to avoid doc-tool duplication."""
118+
def test_all_matches_expected(self):
119+
"""``__all__`` matches the expected list exactly."""
79120
import PowerPlatform.Dataverse.core as m
80121

81-
self.assertEqual(m.__all__, [])
122+
self.assertEqual(sorted(m.__all__), sorted(CORE_EXPECTED))
82123

83124
def test_expected_symbols_importable(self):
84125
"""Every expected public symbol is reachable from the package namespace."""
@@ -113,11 +154,11 @@ def test_identity(self):
113154
class TestModelsExports(unittest.TestCase):
114155
"""Verify package-level imports for PowerPlatform.Dataverse.models."""
115156

116-
def test_all_is_empty(self):
117-
"""``__all__`` is deliberately empty to avoid doc-tool duplication."""
157+
def test_all_matches_expected(self):
158+
"""``__all__`` matches the expected list exactly."""
118159
import PowerPlatform.Dataverse.models as m
119160

120-
self.assertEqual(m.__all__, [])
161+
self.assertEqual(sorted(m.__all__), sorted(MODELS_EXPECTED))
121162

122163
def test_expected_symbols_importable(self):
123164
"""Every expected public symbol is reachable from the package namespace."""
@@ -175,11 +216,11 @@ def test_identity(self):
175216
class TestOperationsExports(unittest.TestCase):
176217
"""Verify package-level imports for PowerPlatform.Dataverse.operations."""
177218

178-
def test_all_is_empty(self):
179-
"""``__all__`` is deliberately empty to avoid doc-tool duplication."""
219+
def test_all_matches_expected(self):
220+
"""``__all__`` matches the expected list exactly."""
180221
import PowerPlatform.Dataverse.operations as m
181222

182-
self.assertEqual(m.__all__, [])
223+
self.assertEqual(sorted(m.__all__), sorted(OPERATIONS_EXPECTED))
183224

184225
def test_expected_symbols_importable(self):
185226
"""Every expected public symbol is reachable from the package namespace."""

0 commit comments

Comments
 (0)