-
-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Milestone
Description
- cattrs version: 23.2.3
- Python version: 3.11.2
- Operating System: Ubuntu 22.04
Description
I expect the method SelectorConfig.load() to convert the toml text to the defaultdict type in SelectorConfig.properties. Instead, it is converted as dict
How to configure structurizing to make it recognizing the exact type which is DefaultDict[str, LineStringProperties] ?
What I Did
config_converter = TomlkitConverter()
@attrs.define
class LineStringProperties:
pinned: bool = False
comment: str = ''
theme_group: str = LIGHT_THEME
@attrs.define
class SelectorConfig:
properties: DefaultDict[str, LineStringProperties] = attrs.field(factory=lambda: defaultdict(LineStringProperties))
@staticmethod
def load(config_path: Path) -> 'SelectorConfig':
if not config_path.exists():
return SelectorConfig()
text = config_path.read_text()
config = config_converter.loads(text, SelectorConfig)
return configReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels