Repository: matplotlib/matplotlib
File: lib/matplotlib/legend.py (Python)

Code before:
                                    'text.color')
        if isinstance(labelcolor, str) and labelcolor in color_getters:
            getter_names = color_getters[labelcolor]
            for handle, text in zip(self.legend_handles, self.texts):
                try:
                    if handle.get_array() is not None:
                        continue
                except AttributeError:
                    pass
                for getter_name in getter_names:
                    try:
                        color = getattr(handle, getter_name)()
                        if isinstance(color, np.ndarray):
                            if color.size == 0:
                                continue
                            elif (
                                color.shape[0] == 1
                                or np.isclose(color, color[0]).all()
                            ):
                                text.set_color(color[0])
                            else:
                                pass
                        elif isinstance(color, str) and str(color).lower() == 'none':
                            continue
                        elif (len(mpl.colors.to_rgba(color)) == 4
                              and mpl.colors.to_rgba(color)[3] == 0):
                                continue
                        else:
                            text.set_color(color)
                        break
                    except AttributeError:
                        continue
                else:
                    text.set_color('none')
        elif cbook._str_equal(labelcolor, 'none'):
            for text in self.texts:
                text.set_color(labelcolor)
        elif np.iterable(labelcolor):
            for text, color in zip(self.texts,
                                   itertools.cycle(
                                       colors.to_rgba_array(labelcolor))):
                text.set_color(color)
        else:
            raise ValueError(f"Invalid labelcolor: {labelcolor!r}")

    def _set_artist_props(self, a):
        """
        Set the boilerplate props for artists added to Axes.
        """
        a.set_figure(self.get_figure(root=False))
        if self.isaxes:

Review comment (suggestion):
`to_rgba()` always returns a 4-element tuple
```suggestion
                        elif mpl.colors.to_rgba(color)[3] == 0:
```

Code after:
                                    'text.color')
        if isinstance(labelcolor, str) and labelcolor in color_getters:
            getter_names = color_getters[labelcolor]
            for handle, text in zip(self.legend_handles, self.texts):
                try:
                    if handle.get_array() is not None:
                        continue
                except AttributeError:
                    pass
                for getter_name in getter_names:
                    try:
                        color = getattr(handle, getter_name)()
                    except AttributeError:
                        continue
                    if isinstance(color, np.ndarray):
                        if color.size == 0:
                            continue
                        elif (color.shape[0] == 1 or np.isclose(color, color[0]).all()):
                            text.set_color(color[0])
                        else:
                            pass
                    elif cbook._str_lower_equal(color, 'none'):
                        continue
                    elif mpl.colors.to_rgba(color)[3] == 0:
                        continue
                    else:
                        text.set_color(color)
                    break
        elif cbook._str_equal(labelcolor, 'none'):
            for text in self.texts:
                text.set_color(labelcolor)
        elif np.iterable(labelcolor):
            for text, color in zip(self.texts,
                                   itertools.cycle(
                                       colors.to_rgba_array(labelcolor))):
                text.set_color(color)
        else:
            raise ValueError(f"Invalid labelcolor: {labelcolor!r}")

    def _set_artist_props(self, a):
        """
        Set the boilerplate props for artists added to Axes.
        """
        a.set_figure(self.get_figure(root=False))
        if self.isaxes:
            a.axes = self.axes

        a.set_transform(self.get_transform())

    @_docstring.interpd
    def set_loc(self, loc=None):