From 1d65ab62cb9fd6bb29f1dd7b9aed7a4f371fc08c Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 31 Dec 2023 13:02:23 +0100 Subject: [PATCH] style: apply ruff suggestion Fixes the only error reported by ruff using default settings: E721 Do not compare types, use `isinstance()` --- tests/common.py | 2 +- yamllint/config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common.py b/tests/common.py index 65af63b..640be53 100644 --- a/tests/common.py +++ b/tests/common.py @@ -62,7 +62,7 @@ def build_temp_workspace(files): if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) - if type(content) is list: + if isinstance(content, list): os.mkdir(path) else: mode = 'wb' if isinstance(content, bytes) else 'w' diff --git a/yamllint/config.py b/yamllint/config.py index b07229f..5f0ef91 100644 --- a/yamllint/config.py +++ b/yamllint/config.py @@ -205,7 +205,7 @@ def validate_rule_conf(rule, conf): # Example: CONF = {option: ['flag1', 'flag2', int]} # → {option: [flag1]} → {option: [42, flag1, flag2]} elif isinstance(options[optkey], list): - if (type(conf[optkey]) is not list or + if (not isinstance(conf[optkey], list) or any(flag not in options[optkey] and type(flag) not in options[optkey] for flag in conf[optkey])):