Coverage for src/edwh_restic_plugin/helpers.py: 83%

6 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-10 20:53 +0100

1import typing 

2 

3T = typing.TypeVar("T") 

4 

5 

6def fix_tags(tags: typing.Iterable[T | None]) -> list[T]: 

7 """ 

8 Removes all None type elements from the input list. 

9 

10 :param tags: list of strings, some elements may be None 

11 :return: list of strings with all None elements removed 

12 """ 

13 return [tag for tag in tags if tag is not None] 

14 

15 

16def camel_to_snake(s: str) -> str: 

17 return "".join([f"_{c.lower()}" if c.isupper() else c for c in s]).lstrip("_")