Skip to content

Commit

Permalink
Simplify Code.attributes type hint (#195)
Browse files Browse the repository at this point in the history
* Simplify Code.attributes type hint

* Update imports

* Update typehint for Code.attributes

* Rename Code.attributes to Code.extra_attributes
  • Loading branch information
phackstock authored Nov 22, 2022
1 parent 4e39a84 commit ea02177
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions nomenclature/code.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
import re
from typing import Union, List, Dict, Optional, Set
from pydantic import BaseModel, StrictStr, StrictInt, StrictFloat, StrictBool, Field
from typing import Any, Dict, List, Optional, Set, Union

from pydantic import BaseModel, Field


class Code(BaseModel):
"""A simple class for a mapping of a "code" to its attributes"""

name: str
description: Optional[str]
extra_attributes: Union[
Dict[
str,
Union[
StrictStr,
StrictInt,
StrictFloat,
StrictBool,
List,
None,
Dict[
str,
Union[StrictStr, StrictInt, StrictFloat, StrictBool, List, None],
],
],
],
List[StrictStr],
] = {}
extra_attributes: Dict[str, Any] = {}

@classmethod
def from_dict(cls, mapping) -> "Code":
Expand Down

0 comments on commit ea02177

Please sign in to comment.