Skip to content
Snippets Groups Projects
Commit 2fbb962b authored by Podosochnyy Maxim's avatar Podosochnyy Maxim
Browse files

Merge branch 'feature/AUTO-3805' into 'master'

feat: AUTO-3805 CollectionProps type

See merge request !77
parents 475ffc2d 4fc4d559
No related branches found
No related tags found
1 merge request!77feat: AUTO-3805 CollectionProps type
Pipeline #73551 passed with stage
in 33 seconds
from perxis.collections import collections_pb2
from typing import TypedDict
from dataclasses import dataclass, asdict
from typing_extensions import deprecated
......@@ -22,11 +22,18 @@ def make_collection_instances(
return collections
class CollectionProps(TypedDict):
single: bool
system: bool
no_data: bool
hidden: bool
@dataclass
class CollectionProps:
single: bool = False
system: bool = False
no_data: bool = False
hidden: bool = False
no_revisions: bool = False
no_archive: bool = False
no_publish: bool = False
def to_dict(self) -> dict:
return asdict(self) # noqa
def init_collections(
......@@ -40,8 +47,13 @@ def init_collections(
with open(f"{schemes_dir}/{collection_id}.json", "r") as file:
collection_schema = file.read()
props = collections_settings_mapping.get(collection_id) or CollectionProps()
if not isinstance(props, CollectionProps):
raise TypeError("collections_settings_mapping value must be an instance of CollectionProps")
kwargs = {
**(collections_settings_mapping.get(collection_id) or {}),
**props.to_dict(),
"id": collection_id,
"name": collection_name,
"schema": collection_schema,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment