Skip to content

Commit 8be4eae

Browse files
committed
Fixes following PR review.
1 parent 5840fee commit 8be4eae

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

lib/matplotlib/__init__.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,19 @@ def ge(self, level):
387387

388388

389389
def _logged_cached(fmt, func=None):
390-
if func is None:
390+
"""
391+
Decorator that logs a function's return value, and memoizes that value.
392+
393+
After ::
394+
395+
@_logged_cached(fmt)
396+
def func(): ...
397+
398+
the first call to *func* will log its return value at the DEBUG level using
399+
%-format string *fmt*, and memoize it; later calls to *func* will directly
400+
return that value.
401+
"""
402+
if func is None: # Return the actual decorator.
391403
return functools.partial(_logged_cached, fmt)
392404

393405
called = False
@@ -569,7 +581,7 @@ def _get_xdg_config_dir():
569581
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
570582
"""
571583
return (os.environ.get('XDG_CONFIG_HOME')
572-
or (Path(get_home(), ".config")
584+
or (str(Path(get_home(), ".config"))
573585
if get_home()
574586
else None))
575587

@@ -581,21 +593,21 @@ def _get_xdg_cache_dir():
581593
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
582594
"""
583595
return (os.environ.get('XDG_CACHE_HOME')
584-
or (Path(get_home(), ".cache")
596+
or (str(Path(get_home(), ".cache"))
585597
if get_home()
586598
else None))
587599

588600

589601
def _get_config_or_cache_dir(xdg_base):
590602
configdir = os.environ.get('MPLCONFIGDIR')
591-
configdir = (
592-
Path(configdir).resolve()
593-
if configdir
594-
else Path(xdg_base, "matplotlib")
595-
if sys.platform.startswith(('linux', 'freebsd')) and xdg_base
596-
else Path(get_home(), ".matplotlib")
597-
if get_home()
598-
else None)
603+
if configdir:
604+
configdir = Path(configdir).resolve()
605+
elif sys.platform.startswith(('linux', 'freebsd')) and xdg_base:
606+
configdir = Path(xdg_base, "matplotlib")
607+
elif get_home():
608+
configdir = Path(get_home(), ".matplotlib")
609+
else:
610+
configdir = None
599611

600612
if configdir:
601613
try:

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ class so far, an alias named ``get_alias`` will be defined; the same will
19841984
can be used by `~.normalize_kwargs` (which assumes that higher priority
19851985
aliases come last).
19861986
"""
1987-
if cls is None:
1987+
if cls is None: # Return the actual class decorator.
19881988
return functools.partial(_define_aliases, alias_d)
19891989

19901990
def make_alias(name): # Enforce a closure over *name*.

lib/matplotlib/testing/compare.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import matplotlib
2020
from matplotlib.testing.exceptions import ImageComparisonFailure
2121
from matplotlib import _png, cbook
22-
from matplotlib import cbook
2322

2423
__all__ = ['compare_float', 'compare_images', 'comparable_formats']
2524

0 commit comments

Comments
 (0)