Redact user-specific absolute paths. Keeps only the last 2 path components when possible.
(pathlike: object)
| 340 | |
| 341 | |
| 342 | def _safe_tail(pathlike: object) -> str: |
| 343 | """Redact user-specific absolute paths. |
| 344 | |
| 345 | Keeps only the last 2 path components when possible. |
| 346 | """ |
| 347 | try: |
| 348 | p = Path(str(pathlike)) |
| 349 | parts = p.parts |
| 350 | if len(parts) >= 2: |
| 351 | return str(Path(*parts[-2:]).as_posix()) |
| 352 | return str(p.as_posix()) |
| 353 | except Exception: |
| 354 | return str(pathlike) |
| 355 | |
| 356 | |
| 357 | def _module_version(module_name: str) -> str: |
no outgoing calls
no test coverage detected