Spaces:
Sleeping

File size: 452 Bytes
a812c01
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""Bolna substitutes absent %(param)s values as literal strings like "None" —
normalize those artifacts to real nulls before they reach storage."""

from typing import Optional

_NULL_ARTIFACTS = {"none", "null", "", "undefined", "not applicable", "n/a", "nil"}


def clean(value: Optional[str]) -> Optional[str]:
    if value is None:
        return None
    if value.strip().lower() in _NULL_ARTIFACTS:
        return None
    return value.strip()