Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2cd6b2

Browse files
committed
TYP: Make mypy stricter on error code checking
These options are based on Scientific Python development guide: https://learn.scientific-python.org/development/guides/repo-review/?repo=matplotlib%2Fmatplotlib&branch=main
1 parent 91a82ea commit f2cd6b2

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

lib/matplotlib/patheffects.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Normal(AbstractPathEffect): ...
5555
class Stroke(AbstractPathEffect):
5656
def __init__(self, offset: tuple[float, float] = ..., **kwargs) -> None: ...
5757
# rgbFace becomes non-optional
58-
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore
58+
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override]
5959

6060
class withStroke(Stroke): ...
6161

@@ -69,7 +69,7 @@ class SimplePatchShadow(AbstractPathEffect):
6969
**kwargs
7070
) -> None: ...
7171
# rgbFace becomes non-optional
72-
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore
72+
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override]
7373

7474
class withSimplePatchShadow(SimplePatchShadow): ...
7575

@@ -83,13 +83,13 @@ class SimpleLineShadow(AbstractPathEffect):
8383
**kwargs
8484
) -> None: ...
8585
# rgbFace becomes non-optional
86-
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore
86+
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override]
8787

8888
class PathPatchEffect(AbstractPathEffect):
8989
patch: Patch
9090
def __init__(self, offset: tuple[float, float] = ..., **kwargs) -> None: ...
9191
# rgbFace becomes non-optional
92-
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore
92+
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override]
9393

9494
class TickedStroke(AbstractPathEffect):
9595
def __init__(
@@ -101,6 +101,6 @@ class TickedStroke(AbstractPathEffect):
101101
**kwargs
102102
) -> None: ...
103103
# rgbFace becomes non-optional
104-
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore
104+
def draw_path(self, renderer: RendererBase, gc: GraphicsContextBase, tpath: Path, affine: Transform, rgbFace: ColorType) -> None: ... # type: ignore[override]
105105

106106
class withTickedStroke(TickedStroke): ...

lib/matplotlib/pyplot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def install_repl_displayhook() -> None:
224224
ip.events.register("post_execute", _draw_all_if_interactive)
225225
_REPL_DISPLAYHOOK = _ReplDisplayHook.IPYTHON
226226

227-
from IPython.core.pylabtools import backend2gui # type: ignore
227+
from IPython.core.pylabtools import backend2gui
228228
# trigger IPython's eventloop integration, if available
229229
ipython_gui_name = backend2gui.get(get_backend())
230230
if ipython_gui_name:
@@ -235,7 +235,7 @@ def uninstall_repl_displayhook() -> None:
235235
"""Disconnect from the display hook of the current shell."""
236236
global _REPL_DISPLAYHOOK
237237
if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON:
238-
from IPython import get_ipython # type: ignore
238+
from IPython import get_ipython
239239
ip = get_ipython()
240240
ip.events.unregister("post_execute", _draw_all_if_interactive)
241241
_REPL_DISPLAYHOOK = _ReplDisplayHook.NONE
@@ -744,7 +744,7 @@ def xkcd(
744744
"xkcd mode is not compatible with text.usetex = True")
745745

746746
stack = ExitStack()
747-
stack.callback(dict.update, rcParams, rcParams.copy()) # type: ignore
747+
stack.callback(dict.update, rcParams, rcParams.copy()) # type: ignore[arg-type]
748748

749749
from matplotlib import patheffects
750750
rcParams.update({
@@ -2501,9 +2501,9 @@ def polar(*args, **kwargs) -> list[Line2D]:
25012501
# requested, ignore rcParams['backend'] and force selection of a backend that
25022502
# is compatible with the current running interactive framework.
25032503
if (rcParams["backend_fallback"]
2504-
and rcParams._get_backend_or_none() in ( # type: ignore
2504+
and rcParams._get_backend_or_none() in ( # type: ignore[attr-defined]
25052505
set(rcsetup.interactive_bk) - {'WebAgg', 'nbAgg'})
2506-
and cbook._get_running_interactive_framework()): # type: ignore
2506+
and cbook._get_running_interactive_framework()):
25072507
rcParams._set("backend", rcsetup._auto_backend_sentinel)
25082508

25092509
# fmt: on

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ convention = "numpy"
208208

209209
[tool.mypy]
210210
ignore_missing_imports = true
211+
enable_error_code = [
212+
"ignore-without-code",
213+
"redundant-expr",
214+
"truthy-bool",
215+
]
211216
enable_incomplete_feature = [
212217
"Unpack",
213218
]

0 commit comments

Comments
 (0)