Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit810a43b

Browse files
authored
Merge pull request#27796 from QuLogic/stricter-mypy
Make mypy a bit stricter
2 parentsaf80c90 +bbd3723 commit810a43b

File tree

7 files changed

+38
-19
lines changed

7 files changed

+38
-19
lines changed

‎.github/workflows/reviewdog.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ jobs:
5555
REVIEWDOG_GITHUB_API_TOKEN:${{ secrets.GITHUB_TOKEN }}
5656
run:|
5757
set -o pipefail
58-
mypy --config pyproject.toml lib/matplotlib \
59-
--follow-imports silent | \
58+
mypy --config pyproject.toml | \
6059
reviewdog -f=mypy -name=mypy \
6160
-tee -reporter=github-check -filter-mode nofilter
6261

‎lib/matplotlib/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def matplotlib_fname() -> str: ...
6868
classRcParams(dict[str,Any]):
6969
validate:dict[str,Callable]
7070
def__init__(self,*args,**kwargs)->None: ...
71+
def_set(self,key:str,val:Any)->None: ...
72+
def_get(self,key:str)->Any: ...
7173
def__setitem__(self,key:str,val:Any)->None: ...
7274
def__getitem__(self,key:str)->Any: ...
7375
def__iter__(self)->Generator[str,None,None]: ...

‎lib/matplotlib/_type1font.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
v1.1, 1993. ISBN 0-201-57044-0.
2222
"""
2323

24+
from __future__importannotations
25+
2426
importbinascii
2527
importfunctools
2628
importlogging
2729
importre
2830
importstring
2931
importstruct
32+
importtypingasT
3033

3134
importnumpyasnp
3235

@@ -171,7 +174,7 @@ def value(self):
171174
returnfloat(self.raw)
172175

173176

174-
def_tokenize(data:bytes,skip_ws:bool):
177+
def_tokenize(data:bytes,skip_ws:bool)->T.Generator[_Token,int,None]:
175178
"""
176179
A generator that produces _Token instances from Type-1 font code.
177180
@@ -194,7 +197,7 @@ def _tokenize(data: bytes, skip_ws: bool):
194197
hex_re=re.compile(r'^<[0-9a-fA-F\0\t\r\f\n ]*>$')
195198
oct_re=re.compile(r'[0-7]{1,3}')
196199
pos=0
197-
next_binary=None
200+
next_binary:int|None=None
198201

199202
whilepos<len(text):
200203
ifnext_binaryisnotNone:

‎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
classStroke(AbstractPathEffect):
5656
def__init__(self,offset:tuple[float,float]= ...,**kwargs)->None: ...
5757
# rgbFace becomes non-optional
58-
defdraw_path(self,renderer:RendererBase,gc:GraphicsContextBase,tpath:Path,affine:Transform,rgbFace:ColorType)->None: ...# type: ignore
58+
defdraw_path(self,renderer:RendererBase,gc:GraphicsContextBase,tpath:Path,affine:Transform,rgbFace:ColorType)->None: ...# type: ignore[override]
5959

6060
classwithStroke(Stroke): ...
6161

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

7474
classwithSimplePatchShadow(SimplePatchShadow): ...
7575

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

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

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

106106
classwithTickedStroke(TickedStroke): ...

‎lib/matplotlib/projections/__init__.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
from .geoimportAitoffAxes,HammerAxes,LambertAxes,MollweideAxes
2-
from .polarimportPolarAxes
1+
from .geoimport (
2+
AitoffAxesasAitoffAxes,
3+
HammerAxesasHammerAxes,
4+
LambertAxesasLambertAxes,
5+
MollweideAxesasMollweideAxes,
6+
)
7+
from .polarimportPolarAxesasPolarAxes
38
from ..axesimportAxes
49

510
classProjectionRegistry:

‎lib/matplotlib/pyplot.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
frommatplotlib.artistimportArtist
7070
frommatplotlib.axesimportAxes
7171
frommatplotlib.axesimportSubplot# noqa: F401
72-
frommatplotlib.projectionsimportPolarAxes# type: ignore
72+
frommatplotlib.projectionsimportPolarAxes
7373
frommatplotlibimportmlab# for detrend_none, window_hanning
7474
frommatplotlib.scaleimportget_scale_names# noqa: F401
7575

@@ -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-
fromIPython.core.pylabtoolsimportbackend2gui# type: ignore
227+
fromIPython.core.pylabtoolsimportbackend2gui
228228
# trigger IPython's eventloop integration, if available
229229
ipython_gui_name=backend2gui.get(get_backend())
230230
ifipython_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_DISPLAYHOOKis_ReplDisplayHook.IPYTHON:
238-
fromIPythonimportget_ipython# type: ignore
238+
fromIPythonimportget_ipython
239239
ip=get_ipython()
240240
ip.events.unregister("post_execute",_draw_all_if_interactive)
241241
_REPL_DISPLAYHOOK=_ReplDisplayHook.NONE
@@ -274,7 +274,7 @@ def _get_backend_mod() -> type[matplotlib.backend_bases._Backend]:
274274
# Use rcParams._get("backend") to avoid going through the fallback
275275
# logic (which will (re)import pyplot and then call switch_backend if
276276
# we need to resolve the auto sentinel)
277-
switch_backend(rcParams._get("backend"))# type: ignore[attr-defined]
277+
switch_backend(rcParams._get("backend"))
278278
returncast(type[matplotlib.backend_bases._Backend],_backend_mod)
279279

280280

@@ -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
frommatplotlibimportpatheffects
750750
rcParams.update({
@@ -2501,10 +2501,10 @@ 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-
andrcParams._get_backend_or_none()in (# type: ignore
2504+
andrcParams._get_backend_or_none()in (# type: ignore[attr-defined]
25052505
set(rcsetup.interactive_bk)- {'WebAgg','nbAgg'})
2506-
andcbook._get_running_interactive_framework()):# type: ignore
2507-
rcParams._set("backend",rcsetup._auto_backend_sentinel)# type: ignore
2506+
andcbook._get_running_interactive_framework()):
2507+
rcParams._set("backend",rcsetup._auto_backend_sentinel)
25082508

25092509
# fmt: on
25102510

‎pyproject.toml

Lines changed: 10 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
]
@@ -227,6 +232,11 @@ exclude = [
227232
# stubtest will import and run, opening a figure if not excluded
228233
".*/tinypages"
229234
]
235+
files = [
236+
"lib/matplotlib",
237+
]
238+
follow_imports ="silent"
239+
warn_unreachable =true
230240

231241
[tool.rstcheck]
232242
ignore_directives = [

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp