class Settings:
csv_file_path: Path
column_labels: list[str | None]
... # Lots of other stuff
def do_stuff(settings: Settings):
df = pd.load_csv(settings.csv_file_path)
settings.column_labels = [
label1 or label2
for label1, label2 in zip(settings.column_labels, df.columns)
]
# Error, type checker doesn't understand that it's now a list[str]
label: str = settings.column_labels[0]