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

Code before:
            mpl._val_or_rc(
                grid_linestyle,
                f"grid.{major_minor}.linestyle",
                "grid.linestyle",
            )
        )
        grid_linewidth = (
            mpl._val_or_rc(
                grid_linewidth,
                f"grid.{major_minor}.linewidth",
                "grid.linewidth",
            )
        )
        if grid_alpha is None and not mcolors._has_alpha_channel(grid_color):
            # alpha precedence: kwarg > color alpha > rcParams['grid.alpha']
            # Note: only resolve to rcParams if the color does not have alpha
            # otherwise `grid(color=(1, 1, 1, 0.5))` would work like
            #   grid(color=(1, 1, 1, 0.5), alpha=rcParams['grid.alpha'])
            # so the that the rcParams default would override color alpha.
            grid_alpha = (
                # grid_alpha is None so we can use the first key
                mpl._val_or_rc(
                    mpl.rcParams[f"grid.{major_minor}.alpha"],
                    "grid.alpha",
                )
            )

        grid_kw = {k[5:]: v for k, v in kwargs.items() if k != "rotation_mode"}

        self.tick1line = mlines.Line2D(
            [], [],
            color=color, linestyle="none", zorder=zorder, visible=tick1On,
            markeredgecolor=color, markersize=self._size, markeredgewidth=self._width,
        )
        self.tick2line = mlines.Line2D(
            [], [],
            color=color, linestyle="none", zorder=zorder, visible=tick2On,
            markeredgecolor=color, markersize=self._size, markeredgewidth=self._width,
        )
        self.gridline = mlines.Line2D(
            [], [],
            color=grid_color, alpha=grid_alpha, visible=gridOn,
            linestyle=grid_linestyle, linewidth=grid_linewidth, marker="",
            **grid_kw,
        )
        self.gridline.get_path()._interpolation_steps = \
            GRIDLINE_INTERPOLATION_STEPS
        self.label1 = mtext.Text(
            np.nan, np.nan,
            fontsize=labelsize, color=labelcolor, visible=label1On,
            fontfamily=labelfontfamily, rotation=self._labelrotation[1])

Review comment (suggestion):
```suggestion
            grid_alpha = mpl._val_or_rc(
                # grid_alpha is None so we can use the first key
                mpl.rcParams[f"grid.{major_minor}.alpha"],
                "grid.alpha",
            )
```

Code after:
            "grid.linestyle",
        )
        grid_linewidth = mpl._val_or_rc(
            grid_linewidth,
            f"grid.{major_minor}.linewidth",
            "grid.linewidth",
        )
        if grid_alpha is None and not mcolors._has_alpha_channel(grid_color):
            # alpha precedence: kwarg > color alpha > rcParams['grid.alpha']
            # Note: only resolve to rcParams if the color does not have alpha
            # otherwise `grid(color=(1, 1, 1, 0.5))` would work like
            #   grid(color=(1, 1, 1, 0.5), alpha=rcParams['grid.alpha'])
            # so the that the rcParams default would override color alpha.
            grid_alpha = mpl._val_or_rc(
                # grid_alpha is None so we can use the first key
                mpl.rcParams[f"grid.{major_minor}.alpha"],
                "grid.alpha",
            )

        grid_kw = {k[5:]: v for k, v in kwargs.items() if k != "rotation_mode"}

        self.tick1line = mlines.Line2D(
            [], [],
            color=color, linestyle="none", zorder=zorder, visible=tick1On,
            markeredgecolor=color, markersize=self._size, markeredgewidth=self._width,
        )
        self.tick2line = mlines.Line2D(
            [], [],
            color=color, linestyle="none", zorder=zorder, visible=tick2On,
            markeredgecolor=color, markersize=self._size, markeredgewidth=self._width,
        )
        self.gridline = mlines.Line2D(
            [], [],
            color=grid_color, alpha=grid_alpha, visible=gridOn,
            linestyle=grid_linestyle, linewidth=grid_linewidth, marker="",
            **grid_kw,
        )
        self.gridline.get_path()._interpolation_steps = \
            GRIDLINE_INTERPOLATION_STEPS
        self.label1 = mtext.Text(
            np.nan, np.nan,
            fontsize=labelsize, color=labelcolor, visible=label1On,
            fontfamily=labelfontfamily, rotation=self._labelrotation[1])
        self.label2 = mtext.Text(
            np.nan, np.nan,
            fontsize=labelsize, color=labelcolor, visible=label2On,
            fontfamily=labelfontfamily, rotation=self._labelrotation[1])

        self._apply_tickdir(tickdir)

        for artist in [self.tick1line, self.tick2line, self.gridline,