| Conditions | 3 |
| Total Lines | 12 |
| Code Lines | 12 |
| Lines | 12 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | from functools import lru_cache |
||
| 6 | View Code Duplication | @lru_cache() |
|
|
|
|||
| 7 | def get_simple_name(cls: type) -> str: |
||
| 8 | cls = cls or NoneType |
||
| 9 | cls_name = getattr(cls, '__name__', None) |
||
| 10 | if not cls_name: |
||
| 11 | cls_name = getattr(cls, '_name', None) |
||
| 12 | if not cls_name: |
||
| 13 | cls_name = repr(cls) |
||
| 14 | cls_name = cls_name.split('[')[0] # Remove generic types. |
||
| 15 | cls_name = cls_name.split('.')[-1] # Remove any . caused by repr. |
||
| 16 | cls_name = cls_name.split(r"'>")[0] # Remove any '>. |
||
| 17 | return cls_name |
||
| 18 |