ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
ChainDefInMenu.ChainProp Class Reference
Collaboration diagram for ChainDefInMenu.ChainProp:

Public Member Functions

def __post_init__ (self)
 

Static Public Attributes

 default_factory
 
 str
 
 int
 
 bool
 

Private Member Functions

def _check_types (self)
 

Detailed Description

Class to hold chain properties with (limited) type-checking

Definition at line 9 of file ChainDefInMenu.py.

Member Function Documentation

◆ __post_init__()

def ChainDefInMenu.ChainProp.__post_init__ (   self)

Definition at line 37 of file ChainDefInMenu.py.

37  def __post_init__(self):
38  f = self._check_types()
39  if f is not None:
40  raise TypeError(f"Expected type of '{f.name}' to be {f.type}, "
41  f"got {repr(getattr(self, f.name))}")
42 

◆ _check_types()

def ChainDefInMenu.ChainProp._check_types (   self)
private
Check field types

Definition at line 23 of file ChainDefInMenu.py.

23  def _check_types(self):
24  """Check field types"""
25  for f in dataclasses.fields(self):
26  actual_type = typing.get_origin(f.type) or f.type
27  value = getattr(self, f.name)
28  if actual_type == list:
29  if value:
30  for el in value:
31  if not isinstance(el, typing.get_args(f.type)):
32  return f
33  elif not isinstance(value, actual_type):
34  return f
35  return None
36 

Member Data Documentation

◆ bool

ChainDefInMenu.ChainProp.bool
static

Definition at line 19 of file ChainDefInMenu.py.

◆ default_factory

ChainDefInMenu.ChainProp.default_factory
static

Definition at line 13 of file ChainDefInMenu.py.

◆ int

ChainDefInMenu.ChainProp.int
static

Definition at line 18 of file ChainDefInMenu.py.

◆ str

ChainDefInMenu.ChainProp.str
static

Definition at line 16 of file ChainDefInMenu.py.


The documentation for this class was generated from the following file: