From fe74aed0486f185280462dad055d58b8d6a4e4a9 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 4 Jun 2025 04:28:35 +0000 Subject: [PATCH] Tweak py to get rid of false positive type hint warns --- .../python_core_plugins/spark_core.py | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/lib_python_core/python_core_plugins/spark_core.py b/src/lib_python_core/python_core_plugins/spark_core.py index 0c5569b29..b5726b3fa 100644 --- a/src/lib_python_core/python_core_plugins/spark_core.py +++ b/src/lib_python_core/python_core_plugins/spark_core.py @@ -306,23 +306,18 @@ def get_security( if not spec: spec = get_contract_spec() sec.set_contract_spec(spec) - is_spot = expiration is None and option_kind is None and strike is None - is_future = expiration is not None and option_kind is None and strike is None - is_option = ( - expiration is not None and option_kind is not None and strike is not None - ) - if is_spot: - sec.set_spot(pycore.PySpot()) - elif is_future: + if expiration and strike and option_kind: + opt = pycore.PyOption() + opt.set_expiration(expiration) + opt.set_is_call(option_kind[0].lower() == "c") + opt.set_strike(strike) + sec.set_option(opt) + elif expiration and not strike and not option_kind: fut = pycore.PyFuture() fut.set_expiration(expiration) sec.set_future(fut) - elif is_option: - opt = pycore.PyOption() - opt.set_expiration(expiration) - opt.set_is_call(option_kind.lower().startswith("c")) - opt.set_strike(strike) - sec.set_option(opt) + elif not expiration and not strike and not option_kind: + sec.set_spot(pycore.PySpot()) else: raise ValueError("Invalid parameters (unable to deduce security type)") return sec