From c48d3f3c42c14fc5091587a9bc9c6d17e1a10a00 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 20 Jan 2026 18:29:52 +0100 Subject: [PATCH 1/4] Remove some noqa --- sublime_lib/_util/collections.py | 2 +- sublime_lib/encodings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sublime_lib/_util/collections.py b/sublime_lib/_util/collections.py index c8578df..f80e852 100644 --- a/sublime_lib/_util/collections.py +++ b/sublime_lib/_util/collections.py @@ -42,7 +42,7 @@ def projection( } -def get_selector(selector: object, default_value: object = None) -> Callable: # noqa: F811 +def get_selector(selector: object, default_value: object = None) -> Callable: if callable(selector): return selector elif isinstance(selector, str): diff --git a/sublime_lib/encodings.py b/sublime_lib/encodings.py index 00be84f..93c97a9 100644 --- a/sublime_lib/encodings.py +++ b/sublime_lib/encodings.py @@ -43,7 +43,7 @@ def to_sublime(name: str) -> str: raise ValueError("Unknown Python encoding {!r}.".format(name)) from None -SUBLIME_TO_STANDARD = { # noqa: E121 +SUBLIME_TO_STANDARD = { "UTF-8": "utf-8", "UTF-8 with BOM": "utf-8-sig", "UTF-16 LE": "utf-16-le", @@ -85,7 +85,7 @@ def to_sublime(name: str) -> str: } -STANDARD_TO_SUBLIME = { # noqa: E121 +STANDARD_TO_SUBLIME = { standard_name: sublime_name for sublime_name, standard_name in SUBLIME_TO_STANDARD.items() } From 09d1f31bfe32b2ab6fd66eb75566c70e30cc9b2c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 20 Jan 2026 18:49:12 +0100 Subject: [PATCH 2/4] Fix typing in show_selection_panel module --- sublime_lib/show_selection_panel.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sublime_lib/show_selection_panel.py b/sublime_lib/show_selection_panel.py index fa2f306..6293ff1 100644 --- a/sublime_lib/show_selection_panel.py +++ b/sublime_lib/show_selection_panel.py @@ -22,9 +22,9 @@ def show_selection_panel( flags: QuickPanelOption = QuickPanelOption.NONE, labels: Sequence[object] | Callable[[_ItemType], object] | None = None, selected: NamedValue | _ItemType = NO_SELECTION, - on_select: Callable[[_ItemType], object] | None = None, - on_cancel: Callable[[], object] | None = None, - on_highlight: Callable[[_ItemType], object] | None = None + on_select: Callable[[_ItemType], None] | None = None, + on_cancel: Callable[[], None] | None = None, + on_highlight: Callable[[_ItemType], None] | None = None ) -> None: """Open a quick panel in the given window to select an item from a list. @@ -113,7 +113,8 @@ def on_done(index: int) -> None: else: selected_index = items.index(selected) - on_highlight_callback = lambda index: on_highlight(items[index]) if on_highlight else None + on_highlight_callback: Callable[[int], None] = \ + lambda index: on_highlight(items[index]) if on_highlight else None if isinstance(flags, str): flags = QuickPanelOption(flags) @@ -127,5 +128,5 @@ def on_done(index: int) -> None: on_select=on_done, flags=flags, # type: ignore selected_index=selected_index, - on_highlight=on_highlight_callback # type: ignore + on_highlight=on_highlight_callback ) From c2b6b38c15905b0e9e371df8a606d55be6273d50 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 20 Jan 2026 19:01:32 +0100 Subject: [PATCH 3/4] Implement projection with Mapping arguments Don't restrict to `dict`, but support arguments to be any `Mapping` object. --- sublime_lib/_util/collections.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sublime_lib/_util/collections.py b/sublime_lib/_util/collections.py index f80e852..804f7ad 100644 --- a/sublime_lib/_util/collections.py +++ b/sublime_lib/_util/collections.py @@ -1,26 +1,22 @@ from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Iterable, Mapping from typing import Callable, TypeVar - _V = TypeVar('_V') __all__ = ['projection', 'get_selector'] -def projection( - d: dict[str, _V], - keys: dict[str, str] | Iterable[str] -) -> dict[str, _V]: +def projection(d: Mapping[str, _V], keys: Mapping[str, str] | Iterable[str]) -> Mapping[str, _V]: """ - Return a new :class:`dict` with keys of ``d`` restricted to values in ``keys``. + Return a new :class:`Mapping` with keys of ``d`` restricted to values in ``keys``. .. code-block:: python >>> projection({'a': 1, 'b': 2}, ['b']) {'b': 2} - If ``keys`` is a :class:`dict`, then it maps keys of the original dict to + If ``keys`` is a :class:`Mapping`, then it maps keys of the original Mapping to keys of the result: .. code-block:: python @@ -28,7 +24,7 @@ def projection( >>> projection({'a': 1, 'b': 2}, {'b': 'c'}) {'c': 2} """ - if isinstance(keys, dict): + if isinstance(keys, Mapping): return { new_key: d[original_key] for original_key, new_key in keys.items() From e28572fe5eb1eef6a1e314c8286e11ee9a25f96f Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 20 Jan 2026 19:05:21 +0100 Subject: [PATCH 4/4] Replace deprecated imports Import Iterable and Mapping from collections.abc --- sublime_lib/resource_path.py | 2 +- sublime_lib/settings_dict.py | 4 ++-- sublime_lib/view_utils.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sublime_lib/resource_path.py b/sublime_lib/resource_path.py index 98c3a72..b16b06e 100644 --- a/sublime_lib/resource_path.py +++ b/sublime_lib/resource_path.py @@ -1,8 +1,8 @@ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections import OrderedDict +from collections.abc import Iterable from pathlib import Path -from typing import Iterable import os import posixpath diff --git a/sublime_lib/settings_dict.py b/sublime_lib/settings_dict.py index 54b8600..0feb0ab 100644 --- a/sublime_lib/settings_dict.py +++ b/sublime_lib/settings_dict.py @@ -1,5 +1,4 @@ from __future__ import annotations -from collections.abc import Mapping from functools import partial from typing import TYPE_CHECKING from uuid import uuid4 @@ -12,7 +11,8 @@ __all__ = ['SettingsDict', 'NamedSettingsDict'] if TYPE_CHECKING: - from typing import Any, Callable, Iterable + from collections.abc import Iterable, Mapping + from typing import Any, Callable from typing_extensions import TypeAlias Value: TypeAlias = bool | str | int | float | list[Any] | dict[str, Any] | None diff --git a/sublime_lib/view_utils.py b/sublime_lib/view_utils.py index a821efc..824004f 100644 --- a/sublime_lib/view_utils.py +++ b/sublime_lib/view_utils.py @@ -4,7 +4,8 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from typing import Any, Generator, Iterable, TypeVar + from collections.abc import Generator, Iterable + from typing import Any, TypeVar from sublime_types import Value EnumType = TypeVar('EnumType', bound=Enum)