Skip to content

Commit

Permalink
feat: conditionally import GitHub helper classes based on test data a…
Browse files Browse the repository at this point in the history
…vailability
  • Loading branch information
jjjermiah committed Feb 4, 2025
1 parent 23f39c1 commit 5fd4cce
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/imgtools/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@
data_images as example_data,
data_paths as example_data_paths,
)
from .github_helper import (
GitHubRelease,
GitHubReleaseAsset,
MedImageTestData,
)

__all__ = [
"GitHubRelease",
"GitHubReleaseAsset",
"MedImageTestData",
"example_data",
"example_data_paths",
]


def is_testdata_available() -> bool:
try:
from github import Github # type: ignore # noqa
import aiohttp # noqa

return True
except ImportError:
return False

Check warning on line 19 in src/imgtools/datasets/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/imgtools/datasets/__init__.py#L18-L19

Added lines #L18 - L19 were not covered by tests


if is_testdata_available():
from .github_helper import (
GitHubRelease,
GitHubReleaseAsset,
MedImageTestData,
)

__all__ += [
"GitHubRelease",
"GitHubReleaseAsset",
"MedImageTestData",
]

0 comments on commit 5fd4cce

Please sign in to comment.