It would be great if we could exclude paths based on a regular expression. For example I would like to be able to exclude any keys that start with an underscore by providing exclude_paths=re.compile('\b_')
I would be happy to open a pull request for this if you would consider it. I'm thinking that anywhere exclude_paths is looked at (such as here) we could first check if the value is a regular expression pattern and evaluate it against the path, otherwise use the existing behavior of checking against the list.
Something like:
def should_exclude_path(new_path: str, exclude_paths: Iterable[str] | re.Pattern) -> bool:
if isinstance(exclude_paths, re.Pattern):
return bool(re.match(exclude_paths, new_path))
else:
return new_path in exclude_paths