@@ -98,10 +98,10 @@ def _backend_module_name(self, backend):
98
98
backend = backend .lower ()
99
99
100
100
# Check if have specific name to module mapping.
101
- backend = self ._name_to_module .get (backend ) or backend
101
+ backend = self ._name_to_module .get (backend , backend )
102
102
103
103
return (backend [9 :] if backend .startswith ("module://" )
104
- else f"matplotlib.backends.backend_{ backend . lower () } " )
104
+ else f"matplotlib.backends.backend_{ backend } " )
105
105
106
106
def _clear (self ):
107
107
# Clear all dynamically-added data, used for testing only.
@@ -136,7 +136,7 @@ def _read_entry_points(self):
136
136
if sys .version_info >= (3 , 10 ):
137
137
entry_points = im .entry_points (group = group )
138
138
else :
139
- entry_points = im .entry_points ().get (group , {} )
139
+ entry_points = im .entry_points ().get (group , () )
140
140
entries = [(entry .name , entry .value ) for entry in entry_points ]
141
141
142
142
# For backward compatibility, if matplotlib-inline and/or ipympl are installed
@@ -199,7 +199,7 @@ def backend_for_gui_framework(self, framework):
199
199
"""
200
200
return self ._GUI_FRAMEWORK_TO_BACKEND .get (framework .lower ())
201
201
202
- def is_valid_backend (self , backend : str ) -> bool :
202
+ def is_valid_backend (self , backend ) :
203
203
"""
204
204
Return True if the backend name is valid, False otherwise.
205
205
@@ -262,7 +262,7 @@ def list_all(self):
262
262
Backend names.
263
263
"""
264
264
self ._ensure_entry_points_loaded ()
265
- return self .list_builtin () + list ( self ._backend_to_gui_framework . keys ())
265
+ return [ * self .list_builtin (), * self ._backend_to_gui_framework ]
266
266
267
267
def list_builtin (self , filter_ = None ):
268
268
"""
@@ -286,19 +286,18 @@ def list_builtin(self, filter_=None):
286
286
return [k for k , v in self ._BUILTIN_BACKEND_TO_GUI_FRAMEWORK .items ()
287
287
if v == "headless" ]
288
288
289
- return list ( self ._BUILTIN_BACKEND_TO_GUI_FRAMEWORK . keys ())
289
+ return [ * self ._BUILTIN_BACKEND_TO_GUI_FRAMEWORK ]
290
290
291
291
def list_gui_frameworks (self ):
292
292
"""
293
- Return list of gui frameworks used by Matplotlib backends.
293
+ Return list of GUI frameworks used by Matplotlib backends.
294
294
295
295
Returns
296
296
-------
297
297
list of str
298
298
GUI framework names.
299
299
"""
300
- return [k for k in self ._GUI_FRAMEWORK_TO_BACKEND .keys ()
301
- if k != "headless" ]
300
+ return [k for k in self ._GUI_FRAMEWORK_TO_BACKEND if k != "headless" ]
302
301
303
302
def load_backend_module (self , backend ):
304
303
"""
@@ -321,7 +320,7 @@ def resolve_backend(self, backend):
321
320
"""
322
321
Return the backend and GUI framework for the specified backend name.
323
322
324
- If the GUI framework is not yet known then it will be determine by loading the
323
+ If the GUI framework is not yet known then it will be determined by loading the
325
324
backend module and checking the ``FigureCanvas.required_interactive_framework``
326
325
attribute.
327
326
@@ -351,8 +350,7 @@ def resolve_backend(self, backend):
351
350
self ._backend_to_gui_framework .get (backend ))
352
351
353
352
# Is backend "module://something"?
354
- if (gui is None and isinstance (backend , str ) and
355
- backend .startswith ("module://" )):
353
+ if gui is None and isinstance (backend , str ) and backend .startswith ("module://" ):
356
354
gui = "unknown"
357
355
358
356
# Is backend a possible entry point?
@@ -389,7 +387,7 @@ def resolve_gui_or_backend(self, gui_or_backend):
389
387
390
388
Returns
391
389
-------
392
- Tuple of backend (str) and GUI framework ( str or None).
390
+ tuple of (str, str or None)
393
391
A non-interactive backend returns None for its GUI framework rather than
394
392
"headless".
395
393
"""
0 commit comments