refactor(copilot): inline MIME format lookup in _infer_format_from_workspace

Collapse 3-line MIME lookup (get → if → return fallback) into a single
`return ... or ...` expression, as noted in self-review.
This commit is contained in:
Zamil Majdy
2026-03-13 22:05:20 +07:00
parent ecbab7f3a0
commit d48eb12d50

View File

@@ -307,10 +307,7 @@ async def _infer_format_from_workspace(
return None
# Try MIME type first, then filename extension.
mime = (info.mime_type or "").split(";", 1)[0].strip().lower()
fmt = MIME_TO_FORMAT.get(mime)
if fmt:
return fmt
return infer_format(info.name)
return MIME_TO_FORMAT.get(mime) or infer_format(info.name)
except (ValueError, FileNotFoundError, OSError, PermissionError):
logger.debug("workspace metadata lookup failed for %s", uri, exc_info=True)
return None