mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-06 07:18:28 +01:00
* build(deps-dev): bump mypy from 1.6.1 to 1.7.0 Bumps [mypy](https://github.com/python/mypy) from 1.6.1 to 1.7.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.6.1...v1.7.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fix misc mypy errors --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ruslan Kuprieiev <[email protected]>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
from dataclasses import asdict, dataclass, field, fields
|
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
|
|
from funcy import compact
|
|
from voluptuous import Required
|
|
|
|
|
|
@dataclass
|
|
class Annotation:
|
|
PARAM_DESC: ClassVar[str] = "desc"
|
|
PARAM_TYPE: ClassVar[str] = "type"
|
|
PARAM_LABELS: ClassVar[str] = "labels"
|
|
PARAM_META: ClassVar[str] = "meta"
|
|
|
|
desc: Optional[str] = None
|
|
type: Optional[str] = None # noqa: A003
|
|
labels: List[str] = field(default_factory=list)
|
|
meta: Dict[str, Any] = field(default_factory=dict)
|
|
|
|
def to_dict(self) -> Dict[str, str]:
|
|
return compact(asdict(self))
|
|
|
|
|
|
@dataclass
|
|
class Artifact:
|
|
PARAM_PATH: ClassVar[str] = "path"
|
|
PARAM_DESC: ClassVar[str] = "desc"
|
|
PARAM_TYPE: ClassVar[str] = "type"
|
|
PARAM_LABELS: ClassVar[str] = "labels"
|
|
PARAM_META: ClassVar[str] = "meta"
|
|
|
|
path: str
|
|
desc: Optional[str] = None
|
|
type: Optional[str] = None # noqa: A003
|
|
labels: List[str] = field(default_factory=list)
|
|
meta: Dict[str, Any] = field(default_factory=dict)
|
|
|
|
def to_dict(self) -> Dict[str, str]:
|
|
return compact(asdict(self))
|
|
|
|
|
|
ANNOTATION_FIELDS = [field.name for field in fields(Annotation)]
|
|
ANNOTATION_SCHEMA = {
|
|
Annotation.PARAM_DESC: str,
|
|
Annotation.PARAM_TYPE: str,
|
|
Annotation.PARAM_LABELS: [str],
|
|
Annotation.PARAM_META: object,
|
|
}
|
|
ARTIFACT_SCHEMA: Dict[Any, Any] = {
|
|
Required(Artifact.PARAM_PATH): str,
|
|
**ANNOTATION_SCHEMA, # type: ignore[arg-type]
|
|
}
|