For delete keys do not allow Any, ignore sub error
only dict, list or str, str will be returned as list Ignore any errors for recursive call because it thinks value is [unknown] -> this should be checked that value is [str, Any] or list[dict[str, Any]]
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import Any, cast
|
||||
|
||||
|
||||
def delete_keys_from_set(
|
||||
set_data: dict[str, Any] | list[Any] | Any, keys: list[str]
|
||||
set_data: dict[str, Any] | list[Any] | str, keys: list[str]
|
||||
) -> dict[str, Any] | list[Any] | Any:
|
||||
"""
|
||||
remove all keys from set_data
|
||||
@@ -26,11 +26,13 @@ def delete_keys_from_set(
|
||||
if key in keys:
|
||||
del set_data[key]
|
||||
if isinstance(value, (dict, list)):
|
||||
delete_keys_from_set(value, keys)
|
||||
delete_keys_from_set(value, keys) # type: ignore Partly unknown
|
||||
elif isinstance(set_data, list):
|
||||
for value in set_data:
|
||||
if isinstance(value, (dict, list)):
|
||||
delete_keys_from_set(value, keys)
|
||||
delete_keys_from_set(value, keys) # type: ignore Partly unknown
|
||||
else:
|
||||
set_data = [set_data]
|
||||
|
||||
return set_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user