Coverage for transformer_lens/conversion_utils/helpers/find_property.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2026-04-17 18:55 +0000

1def find_property(needle: str, haystack: object | dict): 

2 needle_levels = needle.split(".") 

3 first_key = needle_levels.pop(0) 

4 

5 current_level = ( 

6 haystack[first_key] if isinstance(haystack, dict) else getattr(haystack, first_key) 

7 ) 

8 

9 if len(needle_levels) > 0: 

10 return find_property(".".join(needle_levels), current_level) 

11 

12 return current_level