From 3a44b8b626ee27d10e48e95387bb6f26d089f9c0 Mon Sep 17 00:00:00 2001 From: Jo2234 <64789670+Jo2234@users.noreply.github.com> Date: Sat, 28 Feb 2026 13:23:46 +0800 Subject: [PATCH] fix: allow None for addplot and alines kwargs in plot() The validators for 'addplot' and 'alines' kwargs rejected None values, even though None is the documented default. This caused a TypeError when users explicitly passed addplot=None or alines=None (e.g. when conditionally building plot arguments). The fix adds 'value is None or' to both validators so they accept None, matching the Default value and the existing None-checks in the plot() function body (lines 421, 740, 659). Fixes #681 --- src/mplfinance/plotting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mplfinance/plotting.py b/src/mplfinance/plotting.py index 3f5350e..80e0dfa 100644 --- a/src/mplfinance/plotting.py +++ b/src/mplfinance/plotting.py @@ -210,7 +210,7 @@ def _valid_plot_kwargs(): 'addplot' : { 'Default' : None, 'Description' : 'addplot object or sequence of addplot objects (from `mpf.make_addplot()`)', - 'Validator' : lambda value: isinstance(value,dict) or (isinstance(value,list) and all([isinstance(d,dict) for d in value])) }, + 'Validator' : lambda value: value is None or isinstance(value,dict) or (isinstance(value,list) and all([isinstance(d,dict) for d in value])) }, 'savefig' : { 'Default' : None, 'Description' : 'file name, or BytesIO, or dict with key `fname` plus other keys allowed as '+ @@ -271,7 +271,7 @@ def _valid_plot_kwargs(): ' May also be a dict with key `alines` (as date/price pairs described above),'+ ' plus one or more of the following keys:'+ ' `colors`, `linestyle`, `linewidths`, `alpha`.', - 'Validator' : lambda value: _alines_validator(value) }, + 'Validator' : lambda value: value is None or _alines_validator(value) }, 'tlines' : { 'Default' : None, 'Description' : 'Draw one or more TREND LINES by specifying one or more pairs of date[times]'+