Skip to content

Commit 4aa793c

Browse files
committed
Use PathLike feature detection for savefig param
Reworks the previous commit using pathlib.Path in favor of more flexible os.PathLike detection. The purpose of pathlib.Path is basically to provide an os.PathLike interface for other libraries to read (via os.fspath()), but any object can also provide the same interface. If we check for the interface directly, the output options can be extended without adding more type checks. os.PathLike is newer (added in 3.6) than pathlib.Path (3.4), but it looks like mplfinance is already 3.6+, so version compat seems fine.
1 parent 7617810 commit 4aa793c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mplfinance/plotting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import numpy as np
88
import copy
99
import io
10+
import os
1011
import math
11-
import pathlib
1212
import warnings
1313
import statistics as stat
1414

@@ -169,7 +169,7 @@ def _valid_plot_kwargs():
169169
'Validator' : lambda value: isinstance(value,dict) or (isinstance(value,list) and all([isinstance(d,dict) for d in value])) },
170170

171171
'savefig' : { 'Default' : None,
172-
'Validator' : lambda value: isinstance(value,dict) or isinstance(value,str) or isinstance(value, io.BytesIO) or isinstance(value, pathlib.Path) },
172+
'Validator' : lambda value: isinstance(value,dict) or isinstance(value,str) or isinstance(value, io.BytesIO) or isinstance(value, os.PathLike) },
173173

174174
'block' : { 'Default' : None,
175175
'Validator' : lambda value: isinstance(value,bool) },

0 commit comments

Comments
 (0)