Skip to content

Commit

Permalink
Use an xref for Fetch -> Digest.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Jun 8, 2023
1 parent 72b7049 commit e068abe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions science/dataclass/reflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ClassMetadata:

@dataclass_transform()
def documented_dataclass(
doc: str = "",
*,
alias: str | None = None,
init: bool = True,
Expand Down Expand Up @@ -99,6 +100,8 @@ def wrapper(cls: type[_T]) -> type[_D]:
weakref_slot=weakref_slot,
)(cls),
)
if doc:
data_type.__doc__ = doc
return document_dataclass(data_type, ClassMetadata(alias=alias))

return wrapper
Expand Down
20 changes: 11 additions & 9 deletions science/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ def lazy(self) -> bool:
source_type: ClassVar[str] = "binding"


@documented_dataclass(frozen=True, alias="source")
class Fetch:
"""Source a file by fetching it from the internet at scie run-time or scie build-time.
@documented_dataclass(
f"""Source a file by fetching it from the internet at scie run-time or scie build-time.
```{important}
If the file that is being sourced has a `digest` defined, the fetched content will be checked
against the specified digest and a mismatch will lead to an error. Without a digest defined the
content of the fetched file will be used as-is!
```{{important}}
If the file that is being sourced has a [digest](#{Ref(Digest)}) defined, the fetched
content will be checked against the specified digest and a mismatch will lead to an error.
Without a digest defined the content of the fetched file will be used as-is!
```
"""

""",
frozen=True,
alias="source",
)
class Fetch:
url: Url = dataclasses.field(metadata=metadata("The URL of the file content to fetch."))
lazy: bool = dataclasses.field(
default=True,
Expand Down

0 comments on commit e068abe

Please sign in to comment.