@dataclass
class cntr(setup):
source:str = 'S2'
vi:str = 'SW'
# Dataframe containing information on samples
df:pd.DataFrame = pd.DataFrame()
# Available bands
bands:List[str] = field(default_factory=[])
indices:List[str] = [vi] + bands
In the code above, I get this error for the line indices:List[str] = [vi] + bands
:
*** TypeError: can only concatenate list (not "Field") to list
How do I fix this?
You can define
indices
in__post_init__
. It will not appear in therepr
but it will be accessible as a property.You also need to have a callable for
default_factory
, solist
instead of[]
.Here is a simplified example (as I do not know what is
setup
: