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

Commitcd3685f

Browse files
authored
Create RCKeyType (#30316)
* Create RCKeyType* Create RCGroupKeyType* Rename types for consistent naming* Replace str with RcKeyType on RcParams* Replace str with RcKeyType or RcGroupKeyType on matplotlib* Accord pyplot and matplotlib type hints* Correct RcParams dict key type* Correct mypy errors
1 parent73ef257 commitcd3685f

File tree

4 files changed

+402
-12
lines changed

4 files changed

+402
-12
lines changed

‎lib/matplotlib/__init__.pyi‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import contextlib
3939
frompackaging.versionimportVersion
4040

4141
frommatplotlib._apiimportMatplotlibDeprecationWarning
42+
frommatplotlib.typingimportRcKeyType,RcGroupKeyType
4243
fromtypingimportAny,Literal,NamedTuple,overload
4344
frommatplotlib.typingimportLogLevel
4445

@@ -69,18 +70,18 @@ def get_cachedir() -> str: ...
6970
defget_data_path()->str: ...
7071
defmatplotlib_fname()->str: ...
7172

72-
classRcParams(dict[str,Any]):
73+
classRcParams(dict[RcKeyType,Any]):
7374
validate:dict[str,Callable]
7475
def__init__(self,*args,**kwargs)->None: ...
75-
def_set(self,key:str,val:Any)->None: ...
76-
def_get(self,key:str)->Any: ...
76+
def_set(self,key:RcKeyType,val:Any)->None: ...
77+
def_get(self,key:RcKeyType)->Any: ...
7778

7879
def_update_raw(self,other_params:dict|RcParams)->None: ...
7980

8081
def_ensure_has_backend(self)->None: ...
81-
def__setitem__(self,key:str,val:Any)->None: ...
82-
def__getitem__(self,key:str)->Any: ...
83-
def__iter__(self)->Generator[str,None,None]: ...
82+
def__setitem__(self,key:RcKeyType,val:Any)->None: ...
83+
def__getitem__(self,key:RcKeyType)->Any: ...
84+
def__iter__(self)->Generator[RcKeyType,None,None]: ...
8485
def__len__(self)->int: ...
8586
deffind_all(self,pattern:str)->RcParams: ...
8687
defcopy(self)->RcParams: ...
@@ -95,17 +96,17 @@ def rc_params_from_file(
9596
rcParamsDefault:RcParams
9697
rcParams:RcParams
9798
rcParamsOrig:RcParams
98-
defaultParams:dict[str,Any]
99+
defaultParams:dict[RcKeyType,Any]
99100

100-
defrc(group:str,**kwargs)->None: ...
101+
defrc(group:RcGroupKeyType,**kwargs)->None: ...
101102
defrcdefaults()->None: ...
102103
defrc_file_defaults()->None: ...
103104
defrc_file(
104105
fname:str|Path|os.PathLike,*,use_default_template:bool= ...
105106
)->None: ...
106107
@contextlib.contextmanager
107108
defrc_context(
108-
rc:dict[str,Any]|None= ...,fname:str|Path|os.PathLike|None= ...
109+
rc:dict[RcKeyType,Any]|None= ...,fname:str|Path|os.PathLike|None= ...
109110
)->Generator[None,None,None]: ...
110111
defuse(backend:str,*,force:bool= ...)->None: ...
111112
@overload

‎lib/matplotlib/_mathtext.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def __init__(self, default_font_prop: FontProperties, load_glyph_flags: LoadFlag
570570

571571
super().__init__(default_font_prop,load_glyph_flags)
572572
fortexfontin"cal rm tt it bf sf bfit".split():
573-
prop=mpl.rcParams['mathtext.'+texfont]
573+
prop=mpl.rcParams['mathtext.'+texfont]# type: ignore[index]
574574
font=findfont(prop)
575575
self.fontmap[texfont]=font
576576
prop=FontProperties('cmex10')

‎lib/matplotlib/pyplot.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@
146146
MarkerType,
147147
MouseEventType,
148148
PickEventType,
149+
RcGroupKeyType,
150+
RcKeyType,
149151
ResizeEventType,
150152
LogLevel
151153
)
@@ -790,13 +792,13 @@ def pause(interval: float) -> None:
790792

791793

792794
@_copy_docstring_and_deprecators(matplotlib.rc)
793-
defrc(group:str,**kwargs)->None:
795+
defrc(group:RcGroupKeyType,**kwargs)->None:
794796
matplotlib.rc(group,**kwargs)
795797

796798

797799
@_copy_docstring_and_deprecators(matplotlib.rc_context)
798800
defrc_context(
799-
rc:dict[str,Any]|None=None,
801+
rc:dict[RcKeyType,Any]|None=None,
800802
fname:str|pathlib.Path|os.PathLike|None=None,
801803
)->AbstractContextManager[None]:
802804
returnmatplotlib.rc_context(rc,fname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp