Skip to content

Commit

Permalink
Review and CI warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ksunden committed Mar 30, 2023
1 parent fda8600 commit ef5713e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ exclude_lines =
def __str__
def __repr__
if __name__ == .__main__.:
if TYPE_CHECKING:
if typing.TYPE_CHECKING:
3 changes: 3 additions & 0 deletions doc/missing-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.vlines:1"
],
"Axes": [
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.axes:1",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.colorbar:1",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.delaxes:1",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplot2grid:1",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplot_mosaic:1",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.subplots:1",
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.twinx:1",
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@
"""

__all__ = [
__all_ignore__ = [
"__bibtex__",
"__version__",
"__version_info__",
"set_loglevel",
"ExecutableNotFoundError",
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = [
"__bibtex__",
"__version__",
"__version_info__",
"set_loglevel",
"ExecutableNotFoundError",
Expand Down Expand Up @@ -49,8 +50,8 @@ class _VersionInfo(NamedTuple):
releaselevel: str
serial: int

class __getattr__:
__version_info__: _VersionInfo
__version__: str
__version_info__: _VersionInfo

def set_loglevel(level: str) -> None: ...

Expand Down
16 changes: 9 additions & 7 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,8 @@ def sca(ax: Axes) -> None:
Set the current Axes to *ax* and the current Figure to the parent of *ax*.
"""
figure(ax.figure)
# Mypy sees ax.figure as potentially None,
# but if you are calling this, it won't be None
ax.figure.sca(ax) # type: ignore


Expand All @@ -1217,7 +1219,7 @@ def cla() -> None:
## More ways of creating axes ##

@_docstring.dedent_interpd
def subplot(*args, **kwargs) -> matplotlib.axes.Axes:
def subplot(*args, **kwargs) -> Axes:
"""
Add an Axes to the current figure or retrieve an existing Axes.
Expand Down Expand Up @@ -1414,7 +1416,7 @@ def subplots(
subplot_kw: dict[str, Any] | None = None,
gridspec_kw: dict[str, Any] | None = None,
**fig_kw
) -> tuple[Figure, matplotlib.axes.Axes | np.ndarray | SubplotBase]:
) -> tuple[Figure, Axes | np.ndarray | SubplotBase]:
"""
Create a figure and a set of subplots.
Expand Down Expand Up @@ -1578,7 +1580,7 @@ def subplot_mosaic(
gridspec_kw: dict[str, Any] | None = None,
per_subplot_kw: dict[Any, dict[str, Any]] | None = None,
**fig_kw
) -> tuple[Figure, dict[Any, matplotlib.axes.Axes]]:
) -> tuple[Figure, dict[Any, Axes]]:
"""
Build a layout of Axes based on ASCII art or nested lists.
Expand Down Expand Up @@ -1742,7 +1744,7 @@ def subplot2grid(
return fig.add_subplot(subplotspec, **kwargs)


def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
def twinx(ax: Axes | None = None) -> _AxesBase:
"""
Make and return a second axes that shares the *x*-axis. The new axes will
overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
Expand All @@ -1758,7 +1760,7 @@ def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
return ax1


def twiny(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
def twiny(ax: Axes | None = None) -> _AxesBase:
"""
Make and return a second axes that shares the *y*-axis. The new axes will
overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
Expand Down Expand Up @@ -2213,8 +2215,8 @@ def _get_pyplot_commands() -> list[str]:
@_copy_docstring_and_deprecators(Figure.colorbar)
def colorbar(
mappable: ScalarMappable | None = None,
cax: matplotlib.axes.Axes | None = None,
ax: matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes] | None = None,
cax: Axes | None = None,
ax: Axes | Iterable[Axes] | None = None,
**kwargs
) -> Colorbar:
if mappable is None:
Expand Down

0 comments on commit ef5713e

Please sign in to comment.