From 19a74efb885315430a0b96905d292293c9f8b1f2 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 20 Jan 2026 18:41:45 +0100 Subject: [PATCH] Remove obsolete utilities --- sublime_lib/_util/collections.py | 24 ++++-------------------- sublime_lib/show_selection_panel.py | 7 +++---- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/sublime_lib/_util/collections.py b/sublime_lib/_util/collections.py index 6b68c77..c8578df 100644 --- a/sublime_lib/_util/collections.py +++ b/sublime_lib/_util/collections.py @@ -1,11 +1,11 @@ from __future__ import annotations -from collections.abc import Mapping, Sequence -from typing import Callable, Iterable, TypeVar +from collections.abc import Iterable +from typing import Callable, TypeVar _V = TypeVar('_V') -__all__ = ['projection', 'get_selector', 'isiterable', 'ismapping', 'is_sequence_not_str'] +__all__ = ['projection', 'get_selector'] def projection( @@ -47,25 +47,9 @@ def get_selector(selector: object, default_value: object = None) -> Callable: # return selector elif isinstance(selector, str): return lambda this: this.get(selector, default_value) - elif isiterable(selector): + elif isinstance(selector, Iterable): return lambda this: projection(this, selector) # type: ignore else: raise TypeError( 'The selector should be a function, string, or iterable of strings.' ) - - -def isiterable(obj: object) -> bool: - try: - iter(obj) # type: ignore - return True - except TypeError: - return False - - -def ismapping(obj: object) -> bool: - return isinstance(obj, Mapping) - - -def is_sequence_not_str(obj: object) -> bool: - return isinstance(obj, Sequence) and not isinstance(obj, str) diff --git a/sublime_lib/show_selection_panel.py b/sublime_lib/show_selection_panel.py index 2386807..fa2f306 100644 --- a/sublime_lib/show_selection_panel.py +++ b/sublime_lib/show_selection_panel.py @@ -4,7 +4,6 @@ import sublime -from ._util.collections import isiterable from ._util.named_value import NamedValue from .flags import QuickPanelOption @@ -116,10 +115,10 @@ def on_done(index: int) -> None: on_highlight_callback = lambda index: on_highlight(items[index]) if on_highlight else None - if isiterable(flags) and not isinstance(flags, str): - flags = QuickPanelOption(*flags) - else: + if isinstance(flags, str): flags = QuickPanelOption(flags) + else: + flags = QuickPanelOption(*flags) # The signature in the API docs is wrong. # See https://github.com/SublimeTextIssues/Core/issues/2290