Beware of Drupal's Radios FAPI empty handling

Did you ever switch a Drupal Form API element from "select" to "radios" and expect it would behave equally? You're wrong!
Here's (sadly) why...

In our drowl_paragraphs module we wanted to switch a setting from "select" to "radios" to allow style preview:

  1.     $style_boxstyle_options = [];
  2.     // [...]
  3.     $element['style']['style_boxstyle']['style_boxstyle'] = [
  4.       '#type' => 'select',
  5.       '#title' => $this->t('Box style'),
  6.       '#options' => $style_boxstyle_options,
  7.       '#empty_option' => $this->t('- None -'),
  8.       '#default_value' => isset($item->style_boxstyle) ? $item->style_boxstyle : '',
  9.       '#description' => $this->t('Predefined styling of this container.'),
  10.     ];

What I expected was, that it's a simple switch and both would behave indentially regarding their empty value.

But while a "select" automatically adds a "None" option if

  1. '#required' => FALSE

to make it de-selectable, a radio doesn't add such an option. It even doesn't allow for
  1. '#empty_option' => $this->t('- None -')
  2. // or
  3. '#empty_value' => NULL

or similar.

It simply has all radios unchecked by default and if you've checked a radio, you'll be lost for the future.

So the result of my research which lead to to some interesting information here: https://www.drupal.org/project/drupal/issues/1381140 is:

If you switch the Drupal Form Element "select" to "radios" you have to add the empty option yourself and it seems best to use an empty string as key and '#default_value':

  1.     $style_boxstyle_options = [
  2.       // Add none option ("radios" FAPI doesn't provide that)
  3.       '' => $this->t('- None -')
  4.     ];
  5.     // [...]
  6.     $element['style']['style_boxstyle']['style_boxstyle'] = [
  7.       '#type' => 'radios',
  8.       '#title' => $this->t('Box style'),
  9.       '#options' => $style_boxstyle_options,
  10.       '#required' => FALSE,
  11.       '#default_value' => !empty($item->style_boxstyle) ? $item->style_boxstyle : '',
  12.       '#description' => $this->t('Predefined styling of this container.'),
  13.     ];