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

Code before:
    Returns
    -------
    callable
        A wrapped version of *init_func* that handles the optional *axis*.

    Notes
    -----
    If the wrapped constructor defines *axis* as its first argument, the
    parameter is preserved when present. Otherwise, the value `None` is injected
    as the first argument.

    Examples
    --------
    >>> from matplotlib.scale import ScaleBase
    >>> class CustomScale(ScaleBase):
    ...     @_make_axis_parameter_optional
    ...     def __init__(self, axis, custom_param=1):
    ...         self.custom_param = custom_param
    """
    @wraps(init_func)
    def wrapper(self, *args, **kwargs):
        if args and isinstance(args[0], mpl.axis.Axis):
            return init_func(self, *args, **kwargs)
        else:
            # Remove 'axis' from kwargs to avoid double assignment
            return init_func(self, kwargs.pop('axis', None), *args, **kwargs)
    return wrapper


class LinearScale(ScaleBase):
    """
    The default linear scale.
    """

    name = 'linear'

    @_make_axis_parameter_optional
    def __init__(self, axis):
        # This method is present only to prevent inheritance of the base class'
        # constructor docstring, which would otherwise end up interpolated into
        # the docstring of Axis.set_scale.
        """
        """  # noqa: D419

    def set_default_locators_and_formatters(self, axis):
        # docstring inherited
        axis.set_major_locator(AutoLocator())
        axis.set_major_formatter(ScalarFormatter())
        axis.set_minor_formatter(NullFormatter())
        # update the minor locator for x and y axis based on rcParams
        if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or

Review comment (suggestion):
Sorry, I just realized that `kwargs` is used twice in one line, and while it probably _does_ work (that `kwargs` is mutated before expanded as keyword arguments), it may be best to split them apart as it may be confusing.
```suggestion
            # Remove 'axis' from kwargs to avoid double assignment
            axis = kwargs.pop('axis', None)
            return init_func(self, axis, *args, **kwargs)
```

Code after:
    Returns
    -------
    callable
        A wrapped version of *init_func* that handles the optional *axis*.

    Notes
    -----
    If the wrapped constructor defines *axis* as its first argument, the
    parameter is preserved when present. Otherwise, the value `None` is injected
    as the first argument.

    Examples
    --------
    >>> from matplotlib.scale import ScaleBase
    >>> class CustomScale(ScaleBase):
    ...     @_make_axis_parameter_optional
    ...     def __init__(self, axis, custom_param=1):
    ...         self.custom_param = custom_param
    """
    @wraps(init_func)
    def wrapper(self, *args, **kwargs):
        if args and isinstance(args[0], mpl.axis.Axis):
            return init_func(self, *args, **kwargs)
        else:
            # Remove 'axis' from kwargs to avoid double assignment
            axis = kwargs.pop('axis', None)
            return init_func(self, axis, *args, **kwargs)
    return wrapper


class LinearScale(ScaleBase):
    """
    The default linear scale.
    """

    name = 'linear'

    @_make_axis_parameter_optional
    def __init__(self, axis):
        # This method is present only to prevent inheritance of the base class'
        # constructor docstring, which would otherwise end up interpolated into
        # the docstring of Axis.set_scale.
        """
        """  # noqa: D419

    def set_default_locators_and_formatters(self, axis):
        # docstring inherited
        axis.set_major_locator(AutoLocator())
        axis.set_major_formatter(ScalarFormatter())
        axis.set_minor_formatter(NullFormatter())
        # update the minor locator for x and y axis based on rcParams