Skip to content

Commit 18da838

Browse files
committed
Fixes following PR review.
1 parent 5840fee commit 18da838

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

lib/matplotlib/__init__.py

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

388388

389389
def _logged_cached(fmt, func=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+
390403
if func is None:
391404
return functools.partial(_logged_cached, fmt)
392405

@@ -569,7 +582,7 @@ def _get_xdg_config_dir():
569582
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
570583
"""
571584
return (os.environ.get('XDG_CONFIG_HOME')
572-
or (Path(get_home(), ".config")
585+
or (str(Path(get_home(), ".config"))
573586
if get_home()
574587
else None))
575588

@@ -581,21 +594,21 @@ def _get_xdg_cache_dir():
581594
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
582595
"""
583596
return (os.environ.get('XDG_CACHE_HOME')
584-
or (Path(get_home(), ".cache")
597+
or (str(Path(get_home(), ".cache"))
585598
if get_home()
586599
else None))
587600

588601

589602
def _get_config_or_cache_dir(xdg_base):
590603
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)
604+
if configdir:
605+
configdir = Path(configdir).resolve()
606+
elif sys.platform.startswith(('linux', 'freebsd')) and xdg_base:
607+
configdir = Path(xdg_base, "matplotlib")
608+
elif get_home():
609+
configdir = Path(get_home(), ".matplotlib")
610+
else:
611+
configdir = None
599612

600613
if configdir:
601614
try:

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)