I wrote the following function:
def _clean_dict(d):
return {k: v for k, v in d.items() if v is not None}
I want to add type annotations to the function:
def _clean_dict(d: Dict[Any, Any]) -> Dict[Any, Any]:
return {k: v for k, v in d.items() if v is not None}
However, I want to explicitly define that the values inside the returned dictionary cannot be None.
Is there a way to say "Any
type, except NoneType
" or "Every possible value but None
"?