Handle removed `is_rgb` from `fmt 11.2.0` (#3998)

This commit is contained in:
Hind-M 2025-06-30 11:41:55 +02:00 committed by GitHub
parent 6adb2eaa23
commit b3d580e610
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 2 deletions

View File

@ -17,6 +17,20 @@
namespace mambapy
{
// NOTE: These fmt "internals" are for internal use only.
// External users should not use them in their projects.
// Instead, rely on the public API or appropriate abstractions.
// (not sure if they exist at the moment for this specific use case though)
// cf. https://github.com/fmtlib/fmt/issues/4466
bool fmt_is_rgb(const fmt::detail::color_type& color_type)
{
#if FMT_VERSION >= 110200
return !color_type.is_terminal_color();
#else
return color_type.is_rgb;
#endif
}
void bind_submodule_utils(pybind11::module_ m)
{
namespace py = pybind11;
@ -110,7 +124,7 @@ namespace mambapy
return std::nullopt;
}
const auto fg = style.get_foreground();
if (fg.is_rgb)
if (fmt_is_rgb(fg))
{
return { { fmt::rgb(fg.value.rgb_color) } };
}
@ -126,7 +140,7 @@ namespace mambapy
return std::nullopt;
}
const auto bg = style.get_background();
if (bg.is_rgb)
if (fmt_is_rgb(bg))
{
return { { fmt::rgb(bg.value.rgb_color) } };
}