Skip to content

Add module-level exports via __all__ in package __init__.py files#165

Open
abelmilash-msft wants to merge 16 commits into
mainfrom
users/abelmilash/module-level-exports
Open

Add module-level exports via __all__ in package __init__.py files#165
abelmilash-msft wants to merge 16 commits into
mainfrom
users/abelmilash/module-level-exports

Conversation

@abelmilash-msft
Copy link
Copy Markdown
Contributor

Summary

  • Populate __all__ in models/, core/, and operations/ package __init__.py files so users can import directly from the top-level package instead of navigating submodule paths.
  • Update all user-facing examples, README, and skill docs to use the new shorter import paths
  • Fix pre-existing RelationshipInfo dict-style access bugs in relationships.py example

Before / After

# Before
from PowerPlatform.Dataverse.models.record import Record
from PowerPlatform.Dataverse.core.errors import DataverseError

# After
from PowerPlatform.Dataverse.models import Record
from PowerPlatform.Dataverse.core import DataverseError

Abel Milash and others added 3 commits April 21, 2026 21:33
Populate __all__ in models, core, and operations package __init__.py
files so public symbols are importable directly from the package
namespace. Update all user-facing examples, README, and skill docs
to use the new shorter import paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
RelationshipInfo is a dataclass — use attribute access (.relationship_schema_name,
.lookup_schema_name, .relationship_id) instead of dict subscript.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace all remaining .get('Key') dict-style calls with proper
attribute access on RelationshipInfo dataclass fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 22, 2026 06:09
@abelmilash-msft abelmilash-msft requested a review from a team as a code owner April 22, 2026 06:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR flattens the public import surface of the Dataverse SDK by adding package-level re-exports via __all__ in models/, core/, and operations/, and updates docs/examples to use the shorter import paths. It also fixes the RelationshipInfo usage in the relationships example to use attribute access instead of dict-style access.

Changes:

  • Populate __all__ and re-export key symbols in src/PowerPlatform/Dataverse/{models,core,operations}/__init__.py.
  • Update README and skill/example docs to use package-level imports (e.g., from ...models import Record).
  • Fix RelationshipInfo example code to use typed attributes (result.relationship_id, etc.).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/PowerPlatform/Dataverse/operations/init.py Re-export operation namespaces/classes from the package root.
src/PowerPlatform/Dataverse/models/init.py Re-export key model types/helpers (filters, record, query builder, relationship metadata, etc.).
src/PowerPlatform/Dataverse/core/init.py Re-export config/logging/errors at PowerPlatform.Dataverse.core.
src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-use/SKILL.md Update documentation examples to use new package-level imports.
examples/basic/installation_example.py Update example imports to use PowerPlatform.Dataverse.operations and PowerPlatform.Dataverse.core.
examples/basic/functional_testing.py Update example imports to use PowerPlatform.Dataverse.models and PowerPlatform.Dataverse.core.
examples/advanced/walkthrough.py Update example imports to use PowerPlatform.Dataverse.models and PowerPlatform.Dataverse.core.
examples/advanced/relationships.py Update imports and fix RelationshipInfo attribute access usage.
examples/advanced/alternate_keys_upsert.py Update example imports to use PowerPlatform.Dataverse.models.
docs/spec-module-level-exports.md Add a spec describing the module-level export goal and rationale.
README.md Update user-facing snippets to use the new package-level imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/PowerPlatform/Dataverse/operations/__init__.py
Comment thread src/PowerPlatform/Dataverse/operations/__init__.py Outdated
Comment thread docs/spec-module-level-exports.md Outdated
Comment on lines +56 to +60
- `models.filters` → `eq`, `ne`, `gt`, `lt`, `ge`, `le`, `contains`, `startswith`, `endswith`, `filter_in`, `between`, `and_`, `or_`, `not_`
- `models.batch` → `BatchItemResponse`, `BatchResult`
- `models.record` → `Record`
- `models.table_info` → `TableInfo`, `ColumnInfo`, `AlternateKeyInfo`
- `models.relationship` → `OneToManyRelationship`, `ManyToManyRelationship`, `RelationshipInfo` (etc.)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec lists exports that don't match the current implementation: models.filters does not define and_/or_/not_ helpers (composition is via &, |, ~), and relationship classes are named OneToManyRelationshipMetadata/ManyToManyRelationshipMetadata (not OneToManyRelationship/ManyToManyRelationship). To avoid confusion for contributors, update this spec section to reflect the actual public symbols (or add the missing helpers/types if they are intended).

Suggested change
- `models.filters``eq`, `ne`, `gt`, `lt`, `ge`, `le`, `contains`, `startswith`, `endswith`, `filter_in`, `between`, `and_`, `or_`, `not_`
- `models.batch``BatchItemResponse`, `BatchResult`
- `models.record``Record`
- `models.table_info``TableInfo`, `ColumnInfo`, `AlternateKeyInfo`
- `models.relationship``OneToManyRelationship`, `ManyToManyRelationship`, `RelationshipInfo` (etc.)
- `models.filters``eq`, `ne`, `gt`, `lt`, `ge`, `le`, `contains`, `startswith`, `endswith`, `filter_in`, `between`
- `models.batch``BatchItemResponse`, `BatchResult`
- `models.record``Record`
- `models.table_info``TableInfo`, `ColumnInfo`, `AlternateKeyInfo`
- `models.relationship``OneToManyRelationshipMetadata`, `ManyToManyRelationshipMetadata`, `RelationshipInfo` (etc.)

Copilot uses AI. Check for mistakes.
Comment thread src/PowerPlatform/Dataverse/core/__init__.py Outdated
Comment thread src/PowerPlatform/Dataverse/models/__init__.py Outdated
Comment thread src/PowerPlatform/Dataverse/models/__init__.py Outdated
Copilot AI and others added 2 commits April 22, 2026 20:54
Add test_package_exports.py: 3 tests verifying every symbol in __all__
is importable from PowerPlatform.Dataverse.{core,models,operations}.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Abel Milash and others added 11 commits April 22, 2026 13:59
- Merge Copilot's assertIs identity checks into test_package_exports.py
- Add equivalent identity tests for core and models
- Remove test_operations_package_exports.py (Copilot's file)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le-level-exports

# Conflicts:
#	README.md
#	examples/advanced/walkthrough.py
#	src/PowerPlatform/Dataverse/models/__init__.py
The inline comments (# batch, # filters, etc.) restate what the
import statements above already show. Per repo convention, comments
should explain why, not what.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Most build-time tools use pyproject.toml directly, but some legacy
documentation generators look for setup.py. The shim reads version
from VERSION.txt or PackageVersion env var for build pipelines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add __all__ to core/config.py for explicit public API
- Re-export OperationContext from core package (matches public usage)
- Fill identity-check gaps in test_package_exports: covers all 8
  core symbols and all 24 models symbols (was 7 and 15)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The doc generator (autoapi/docfx) was creating duplicate documentation
pages for every re-exported symbol — one at the original submodule path
(e.g. models.record.QueryResult) and one at the package root path
(e.g. models.QueryResult). This caused ~17 cross-reference warnings
in the Microsoft Learn doc build because xrefs in docstrings became
ambiguous between the two paths.

Emptying __all__ stops the doc tool from documenting the re-exports
while keeping all package-root imports working (Python does not consult
__all__ for regular 'from package import Symbol' imports).

Tests updated to assert __all__ is empty and to verify each expected
symbol is still importable from the package namespace.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cleans up ~17 doc-build warnings caused by short-form, wrong-path,
or unresolvable references in docstrings:

- operations/records.py: qualify :class:`QueryResult` and :class:`FilterExpression`
- operations/batch.py: qualify :attr:`BatchResult.responses` and :class:`FilterExpression`;
  replace unresolvable :attr: refs to instance attributes with plain backticks
- operations/tables.py: fully qualify :attr:`AlternateKeyInfo.status`
- models/fetchxml_query.py: correct wrong path (models.fetchxml_query.QueryResult
  → models.record.QueryResult)
- core/log_config.py: qualify :class:`LogConfig` self-reference
- client.py: replace reference to private _ODataClient with plain text

Combined with the empty __all__ change, expected to reduce Microsoft
Learn doc-build warnings from 38 to ~4 (the remaining 4 are auto-generated
:mod: references to models.record in toc.yml that need a doc-repo-side fix).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
These files were experimental scaffolding for doc-generation testing
that is no longer needed for the PR's scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants