-
Notifications
You must be signed in to change notification settings - Fork 32
Add explicit service package exports #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
53d9cd0
Add explicit service package exports
fredvisser 71081bd
Fix tag package import order
fredvisser 0934bdc
lint fix
fredvisser 85e6d58
Fix tag import lint suppression
fredvisser 279ec79
Address review feedback in export test
fredvisser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with AlarmClient for alarm management.""" | ||
|
|
||
| from nisystemlink.clients.alarm._alarm_client import AlarmClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["AlarmClient"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| from ._artifact_client import ArtifactClient | ||
|
|
||
| # flake8: noqa | ||
| """Start here with ArtifactClient for artifact management.""" | ||
|
|
||
| from ._artifact_client import ArtifactClient | ||
|
|
||
| __all__ = ["ArtifactClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| """Start here with AssetManagementClient for asset management.""" | ||
|
|
||
| from nisystemlink.clients.assetmanagement._asset_management_client import ( | ||
| AssetManagementClient, | ||
| ) | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["AssetManagementClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with DataFrameClient for dataframe operations.""" | ||
|
|
||
| from ._data_frame_client import DataFrameClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["DataFrameClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with FeedsClient for feed management.""" | ||
|
|
||
| from ._feeds_client import FeedsClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["FeedsClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with FileClient for file operations.""" | ||
|
|
||
| from ._file_client import FileClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["FileClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with NotebookClient for notebook management.""" | ||
|
|
||
| from ._notebook_client import NotebookClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["NotebookClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with NotificationClient for notification management.""" | ||
|
|
||
| from ._notification_client import NotificationClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["NotificationClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with ProductClient for product management.""" | ||
|
|
||
| from ._product_client import ProductClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["ProductClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with SpecClient for specification management.""" | ||
|
|
||
| from ._spec_client import SpecClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["SpecClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with SystemsClient for system management.""" | ||
|
|
||
| from nisystemlink.clients.systems._systems_client import SystemsClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["SystemsClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,43 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """Start here with TagManager for tag operations and helper types.""" | ||
|
|
||
| from ._data_type import DataType | ||
| from ._retention_type import RetentionType | ||
| from ._tag_data import TagData | ||
| from ._tag_with_aggregates import TagWithAggregates | ||
| from ._async_tag_query_result_collection import AsyncTagQueryResultCollection | ||
| from ._tag_with_aggregates import TagWithAggregates # noqa: I100 | ||
| from ._async_tag_query_result_collection import ( # noqa: I100 | ||
| AsyncTagQueryResultCollection, | ||
| ) | ||
| from ._itag_reader import ITagReader | ||
| from ._itag_writer import ITagWriter | ||
| from ._buffered_tag_writer import BufferedTagWriter | ||
| from ._buffered_tag_writer import BufferedTagWriter # noqa: I100 | ||
| from ._tag_value_reader import TagValueReader | ||
| from ._tag_value_writer import TagValueWriter | ||
| from ._tag_update_fields import TagUpdateFields | ||
| from ._tag_data_update import TagDataUpdate | ||
| from ._tag_update_fields import TagUpdateFields # noqa: I100 | ||
| from ._tag_data_update import TagDataUpdate # noqa: I100 | ||
| from ._tag_path_utilities import TagPathUtilities | ||
| from ._tag_query_result_collection import TagQueryResultCollection | ||
| from ._tag_subscription import TagSubscription | ||
| from ._tag_selection import TagSelection | ||
| from ._tag_manager import TagManager | ||
| from ._tag_selection import TagSelection # noqa: I100 | ||
| from ._tag_manager import TagManager # noqa: I100 | ||
|
|
||
| # flake8: noqa | ||
| __all__ = [ | ||
| "DataType", | ||
| "RetentionType", | ||
| "TagData", | ||
| "TagWithAggregates", | ||
| "AsyncTagQueryResultCollection", | ||
| "ITagReader", | ||
| "ITagWriter", | ||
| "BufferedTagWriter", | ||
| "TagValueReader", | ||
| "TagValueWriter", | ||
| "TagUpdateFields", | ||
| "TagDataUpdate", | ||
| "TagPathUtilities", | ||
| "TagQueryResultCollection", | ||
| "TagSubscription", | ||
| "TagSelection", | ||
| "TagManager", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with TestPlanClient for test plan management.""" | ||
|
|
||
| from ._test_plan_client import TestPlanClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["TestPlanClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with TestMonitorClient for test monitor operations.""" | ||
|
|
||
| from ._test_monitor_client import TestMonitorClient | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["TestMonitorClient"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| """Start here with WorkItemClient for work item operations.""" | ||
|
|
||
| from ._work_item_client import WorkItemClient, WorkItemExecuteApiException | ||
|
|
||
| # flake8: noqa | ||
| __all__ = ["WorkItemClient", "WorkItemExecuteApiException"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| """Validate the public surface declared by each service package.""" | ||
|
|
||
| import ast | ||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
| PACKAGE_EXPORTS = { | ||
| "alarm": ["AlarmClient"], | ||
| "artifact": ["ArtifactClient"], | ||
| "assetmanagement": ["AssetManagementClient"], | ||
| "dataframe": ["DataFrameClient"], | ||
| "feeds": ["FeedsClient"], | ||
| "file": ["FileClient"], | ||
| "notebook": ["NotebookClient"], | ||
| "notification": ["NotificationClient"], | ||
| "product": ["ProductClient"], | ||
| "spec": ["SpecClient"], | ||
| "systems": ["SystemsClient"], | ||
| "tag": [ | ||
| "DataType", | ||
| "RetentionType", | ||
| "TagData", | ||
| "TagWithAggregates", | ||
| "AsyncTagQueryResultCollection", | ||
| "ITagReader", | ||
| "ITagWriter", | ||
| "BufferedTagWriter", | ||
| "TagValueReader", | ||
| "TagValueWriter", | ||
| "TagUpdateFields", | ||
| "TagDataUpdate", | ||
| "TagPathUtilities", | ||
| "TagQueryResultCollection", | ||
| "TagSubscription", | ||
| "TagSelection", | ||
| "TagManager", | ||
| ], | ||
| "test_plan": ["TestPlanClient"], | ||
| "testmonitor": ["TestMonitorClient"], | ||
| "work_item": ["WorkItemClient", "WorkItemExecuteApiException"], | ||
| } | ||
|
|
||
|
|
||
| class TestServicePackageExports(unittest.TestCase): | ||
| """Verify service package docstrings and explicit export lists.""" | ||
|
|
||
| def test_service_package_exports_are_explicit(self): | ||
| """Each service package should document and declare its public exports.""" | ||
| package_root = Path(__file__).resolve().parents[1] / "nisystemlink" / "clients" | ||
|
|
||
| for package_name, exported_names in PACKAGE_EXPORTS.items(): | ||
| with self.subTest(package_name=package_name): | ||
| module_path = package_root / package_name / "__init__.py" | ||
| module = ast.parse(module_path.read_text(encoding="utf-8")) | ||
| imported_names = [] | ||
| declared_exports = None | ||
| module_docstring = ast.get_docstring(module) | ||
|
|
||
| self.assertIsNotNone(module_docstring) | ||
| if module_docstring is None: | ||
| self.fail(f"Missing module docstring in {module_path}") | ||
| self.assertTrue(module_docstring.startswith("Start here with ")) | ||
|
fredvisser marked this conversation as resolved.
|
||
|
|
||
| for node in module.body: | ||
| if isinstance(node, ast.ImportFrom): | ||
| imported_names.extend(alias.name for alias in node.names) | ||
| elif isinstance(node, ast.Assign): | ||
| for target in node.targets: | ||
| if isinstance(target, ast.Name) and target.id == "__all__": | ||
| declared_exports = ast.literal_eval(node.value) | ||
|
|
||
| self.assertEqual(declared_exports, exported_names) | ||
| self.assertCountEqual(imported_names, exported_names) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.