diff --git a/.gitignore b/.gitignore index 68461f0..5b2cef3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # caches +.DS_Store __pycache__ .mypy_cache diff --git a/pyproject.toml b/pyproject.toml index 9c0ec78..98f6d43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,8 @@ build-backend = "hatchling.build" lint = [ "pydocstyle>=6.3.0", "ruff>=0.17.1", - "sublime-text-stubs>=1.4200.0", + "sublime-text-stubs>=4200.1", + "typing-extensions>=4.13.2", ] [tool.hatch.build.targets.sdist] @@ -59,3 +60,10 @@ exclude = [ ] line-length = 100 target-version = "py38" + +[tool.ruff.lint] +extend-select = ["TC"] + +[tool.ruff.lint.flake8-type-checking] +# `sublime` and `sublime_plugin` are always available at runtime. +exempt-modules = ["typing", "sublime", "sublime_plugin"] diff --git a/sublime_lib/activity_indicator.py b/sublime_lib/activity_indicator.py index f2748d0..436feb3 100644 --- a/sublime_lib/activity_indicator.py +++ b/sublime_lib/activity_indicator.py @@ -3,14 +3,18 @@ from abc import ABCMeta, abstractmethod from enum import IntEnum from threading import Lock -from types import TracebackType +from typing import TYPE_CHECKING from uuid import uuid4 import sublime -from typing_extensions import Self from ._util.weak_method import weak_method +if TYPE_CHECKING: + from types import TracebackType + + from typing_extensions import Self + __all__ = ["ActivityIndicator"] diff --git a/sublime_lib/flags.py b/sublime_lib/flags.py index dae14c5..80f10c2 100644 --- a/sublime_lib/flags.py +++ b/sublime_lib/flags.py @@ -33,10 +33,9 @@ import re from enum import EnumMeta, IntEnum, IntFlag from inspect import cleandoc, getdoc -from typing import Callable +from typing import TYPE_CHECKING, Callable import sublime -from typing_extensions import Self from ._util.enum import ( ExtensibleConstructorMeta, @@ -44,6 +43,9 @@ construct_with_alternatives, ) +if TYPE_CHECKING: + from typing_extensions import Self + __all__ = [ "CompletionOptions", "DialogResult", diff --git a/sublime_lib/resource_path.py b/sublime_lib/resource_path.py index e2d2e80..1cd1f07 100644 --- a/sublime_lib/resource_path.py +++ b/sublime_lib/resource_path.py @@ -4,13 +4,16 @@ import posixpath from abc import ABCMeta, abstractmethod from collections import OrderedDict -from collections.abc import Iterable from pathlib import Path +from typing import TYPE_CHECKING import sublime from ._util.glob import get_glob_matcher +if TYPE_CHECKING: + from collections.abc import Iterable + __all__ = ["ResourcePath"] diff --git a/sublime_lib/view_stream.py b/sublime_lib/view_stream.py index 96ddfc6..4872816 100644 --- a/sublime_lib/view_stream.py +++ b/sublime_lib/view_stream.py @@ -1,15 +1,17 @@ from __future__ import annotations -from collections.abc import Generator from contextlib import contextmanager from io import SEEK_CUR, SEEK_END, SEEK_SET -from typing import Any, TextIO +from typing import TYPE_CHECKING, Any, TextIO import sublime from sublime import Region from ._util.guard import define_guard +if TYPE_CHECKING: + from collections.abc import Generator + @define_guard @contextmanager diff --git a/uv.lock b/uv.lock index 5a5a269..20ad6cb 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 5 requires-python = ">=3.8" resolution-markers = [ "python_full_version >= '3.15'", @@ -64,6 +64,8 @@ lint = [ { name = "pydocstyle" }, { name = "ruff" }, { name = "sublime-text-stubs" }, + { name = "typing-extensions", version = "4.13.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.9'" }, + { name = "typing-extensions", version = "4.16.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.9'" }, ] [package.metadata] @@ -72,14 +74,42 @@ lint = [ lint = [ { name = "pydocstyle", specifier = ">=6.3.0" }, { name = "ruff", specifier = ">=0.17.1" }, - { name = "sublime-text-stubs", specifier = ">=1.4200.0" }, + { name = "sublime-text-stubs", specifier = ">=4200.1" }, + { name = "typing-extensions", specifier = ">=4.13.2" }, ] [[package]] name = "sublime-text-stubs" -version = "1.4200.1" +version = "4200.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/6d/86/92629bc9704ca166380ae1463fde809d2b82fc23d4332effad8e50628a44/sublime_text_stubs-1.4200.1.tar.gz", hash = "sha256:d425ed720c1e5303d6e2969c09c0de2f2b879b1e0b182e3863649d1d933e9183", size = 79906, upload-time = "2026-10-17T11:55:07.944Z" } +sdist = { url = "https://files.pythonhosted.org/packages/76/da/f14bef0625e0ec3bd0e27b0dc7ac4fb7f4225fc289dcc6963a5bc5c00cea/sublime_text_stubs-4200.1.tar.gz", hash = "sha256:2f0d6fd0747e5d2f784194277322cdf094c7adf6d540b82cbe8cfeb418c5bb93", size = 79932, upload-time = "2026-10-17T23:31:04.453Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ab/04/5f61ce771c77d0444e0e2fd6dc15dbb41c71a8dff75c12670c7cc385f00e/sublime_text_stubs-1.4200.1-py3-none-any.whl", hash = "sha256:d0b3b1f163e29fb505504b71bc6caaa4a644307e1bb883b6317d7ab4aa2951de", size = 37287, upload-time = "2026-10-17T11:55:06.776Z" }, + { url = "https://files.pythonhosted.org/packages/07/f7/0b4c09296b8adc1516da74f2582b51ccd9bf0dc32af17646552e1e3d3b8a/sublime_text_stubs-4200.1-py3-none-any.whl", hash = "sha256:0d5ac2c12514d54b4c1f112ab7ec459e1a16e9093e5ab9d6f9c3688a396840d3", size = 37273, upload-time = "2026-10-17T23:31:03.065Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.13.2" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.8.1' and python_full_version < '3.9'", + "python_full_version < '3.8.1'", +] +sdist = { url = "https://files.pythonhosted.org/packages/f6/37/23083fcd6e35492953e8d2aaaa68b860eb422b34627b13f2ce3eb6106061/typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef", size = 106967, upload-time = "2025-04-10T14:19:05.416Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8b/54/b1ae86c0973cc6f0210b53d508ca3641fb6d0c56823f288d108bc7ab3cc8/typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c", size = 45806, upload-time = "2025-04-10T14:19:03.967Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.15'", + "python_full_version >= '3.10' and python_full_version < '3.15'", + "python_full_version == '3.9.*'", +] +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, ]