From 22f4952bab515106b59cf852c384b5d0c1791ac1 Mon Sep 17 00:00:00 2001 From: Joel Ray Holveck Date: Mon, 27 Apr 2026 17:17:08 -0700 Subject: [PATCH] Remove some 10.2 compat symbols, and retag retained compat symbols Most of the retained symbols were moved from #493 to the new #517 issue. The with_cursor issue is not addressed in this change. --- docs/source/usage.rst | 7 +++---- src/mss/base.py | 4 ---- src/mss/darwin.py | 4 ++-- src/mss/factory.py | 2 +- src/mss/linux/__init__.py | 19 ++----------------- src/mss/windows/__init__.py | 4 ++-- src/tests/test_compat_10_1.py | 23 ++--------------------- src/tests/test_compat_exports.py | 8 +------- src/tests/test_compat_linux_api.py | 30 ------------------------------ src/tests/test_setup.py | 1 - 10 files changed, 13 insertions(+), 89 deletions(-) delete mode 100644 src/tests/test_compat_linux_api.py diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 4562b3c3..90ac2763 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -13,7 +13,7 @@ MSS can be used simply as:: # ... For compatibility with existing code, :py:func:`mss.mss` is still available in -10.2, but deprecated:: +11.0, but deprecated:: import mss @@ -21,7 +21,7 @@ For compatibility with existing code, :py:func:`mss.mss` is still available in # ... For compatibility with existing code, platform-specific class names are also -still available in 10.2:: +still available in 11.0, but are also deprecated:: # GNU/Linux from mss.linux import MSS @@ -91,8 +91,7 @@ If you want to choose a particular backend, you can pass the ``backend`` keyword with MSS(backend="xgetimage") as sct: ... -GNU/Linux has multiple backend implementations. Windows also exposes the named ``gdi`` backend, which is currently the -same as ``default``. The GNU/Linux backends are described in their own section below. +GNU/Linux has multiple backend implementations. Windows also exposes the named ``gdi`` backend, which is currently the same as ``default``. The GNU/Linux backends are described in their own section below. GNU/Linux diff --git a/src/mss/base.py b/src/mss/base.py index 85cee1c8..a8005568 100644 --- a/src/mss/base.py +++ b/src/mss/base.py @@ -546,7 +546,3 @@ def with_cursor(self) -> bool: .. versionadded:: 8.0.0 """ return self._impl.with_cursor - - -# TODO(jholveck): #493 Remove compatibility alias after 10.x transition period. -MSSBase = MSS diff --git a/src/mss/darwin.py b/src/mss/darwin.py index 62f2d0e6..cba36e7a 100644 --- a/src/mss/darwin.py +++ b/src/mss/darwin.py @@ -56,9 +56,9 @@ class MSS(_MSS): """ def __init__(self, /, **kwargs: Any) -> None: - # TODO(jholveck): #493 Remove compatibility constructor after 10.x transition period. + # TODO(jholveck): #517 Remove compatibility path once 10.x transition period ends. warnings.warn( - "mss.darwin.MSS is deprecated and will be removed in 11.0; use mss.MSS instead", + "mss.darwin.MSS is deprecated and will be removed in a future release; use mss.MSS instead", DeprecationWarning, stacklevel=2, ) diff --git a/src/mss/factory.py b/src/mss/factory.py index 91a46516..4c1daff4 100644 --- a/src/mss/factory.py +++ b/src/mss/factory.py @@ -13,7 +13,7 @@ def mss(**kwargs: Any) -> MSS: .. deprecated:: 10.2.0 Use :class:`mss.MSS` directly. """ - # TODO(jholveck): #493 Remove compatibility deprecation path once 10.x transition period ends. + # TODO(jholveck): #517 Remove compatibility path once 10.x transition period ends. warnings.warn( "mss.mss is deprecated and will be removed in a future release; use mss.MSS instead", DeprecationWarning, diff --git a/src/mss/linux/__init__.py b/src/mss/linux/__init__.py index 6531433e..3d81b161 100644 --- a/src/mss/linux/__init__.py +++ b/src/mss/linux/__init__.py @@ -7,21 +7,6 @@ from mss.base import MSSImplementation from mss.exception import ScreenShotError -# TODO(jholveck): #493 Remove these legacy symbol re-exports after 10.x transition period. -from mss.linux.xlib import ( # noqa: F401 - CFUNCTIONS, - PLAINMASK, - ZPIXMAP, - Display, - XErrorEvent, - XFixesCursorImage, - XImage, - XRRCrtcInfo, - XRRModeInfo, - XRRScreenResources, - XWindowAttributes, -) - __all__ = ["MSS"] BACKENDS = ["default", "xlib", "xgetimage", "xshmgetimage"] @@ -34,9 +19,9 @@ class MSS(_MSS): """ def __init__(self, /, **kwargs: Any) -> None: - # TODO(jholveck): #493 Remove compatibility constructor after 10.x transition period. + # TODO(jholveck): #517 Remove compatibility path once 10.x transition period ends. warnings.warn( - "mss.linux.MSS is deprecated and will be removed in 11.0; use mss.MSS instead", + "mss.linux.MSS is deprecated and will be removed in a future release; use mss.MSS instead", DeprecationWarning, stacklevel=2, ) diff --git a/src/mss/windows/__init__.py b/src/mss/windows/__init__.py index 723ed9b2..a7e2b51a 100644 --- a/src/mss/windows/__init__.py +++ b/src/mss/windows/__init__.py @@ -21,9 +21,9 @@ class MSS(_MSS): """ def __init__(self, /, **kwargs: Any) -> None: - # TODO(jholveck): #493 Remove compatibility constructor after 10.x transition period. + # TODO(jholveck): #517 Remove compatibility path once 10.x transition period ends. warnings.warn( - "mss.windows.MSS is deprecated and will be removed in 11.0; use mss.MSS instead", + "mss.windows.MSS is deprecated and will be removed in a future release; use mss.MSS instead", DeprecationWarning, stacklevel=2, ) diff --git a/src/tests/test_compat_10_1.py b/src/tests/test_compat_10_1.py index bb23f0bb..7981d27b 100644 --- a/src/tests/test_compat_10_1.py +++ b/src/tests/test_compat_10_1.py @@ -12,7 +12,6 @@ import mss from mss import MSS -from mss.base import MSSBase class PlatformModule(Protocol): @@ -81,27 +80,16 @@ def _platform_factory_from_import_style() -> type[MSS]: _factory_from_module_style, ], ) -def test_mss_factory_documented_styles_return_mssbase(factory_getter: MSSFactoryGetter) -> None: +def test_mss_factory_documented_styles_return_mss(factory_getter: MSSFactoryGetter) -> None: factory = factory_getter() with pytest.warns(DeprecationWarning, match=r"^mss\.mss is deprecated"): context = factory() with context as sct: - assert isinstance(sct, MSSBase) assert isinstance(sct, MSS) -def test_documented_style_platform_import_mss() -> None: - mss_factory = _platform_factory_from_import_style() - - with pytest.warns(DeprecationWarning, match=r"^mss\..*\.MSS is deprecated"): - context = mss_factory() - - with context as sct: - assert isinstance(sct, MSSBase) - - def test_direct_mss_constructor_has_no_deprecation_warning() -> None: with warnings.catch_warnings(record=True) as captured: warnings.simplefilter("always", DeprecationWarning) @@ -110,11 +98,6 @@ def test_direct_mss_constructor_has_no_deprecation_warning() -> None: assert not [warning for warning in captured if issubclass(warning.category, DeprecationWarning)] -def test_mssbase_alias_stays_compatible() -> None: - # 10.1-compatible typing/import path. - assert MSSBase is MSS - - def test_platform_mss_constructor_works_on_current_platform() -> None: mss_platform = _platform_module() @@ -123,7 +106,6 @@ def test_platform_mss_constructor_works_on_current_platform() -> None: with sct_context as sct: assert isinstance(sct, mss_platform.MSS) - assert isinstance(sct, MSSBase) assert isinstance(sct, MSS) @@ -140,7 +122,6 @@ def test_factory_and_platform_constructor_are_compatible_types() -> None: assert type(from_factory) is MSS assert type(from_platform) is mss_platform.MSS assert isinstance(from_platform, MSS) - assert isinstance(from_platform, MSSBase) def test_deprecated_factory_accepts_documented_kwargs() -> None: @@ -164,4 +145,4 @@ def test_deprecated_factory_accepts_documented_kwargs() -> None: context = mss.mss(**kwargs) with context as sct: - assert isinstance(sct, MSSBase) + assert isinstance(sct, MSS) diff --git a/src/tests/test_compat_exports.py b/src/tests/test_compat_exports.py index 92cfefb9..408779e9 100644 --- a/src/tests/test_compat_exports.py +++ b/src/tests/test_compat_exports.py @@ -7,13 +7,7 @@ def test_top_level_export_surface_exists() -> None: - # TODO(jholveck): #493 Remove compatibility-only export checks after 10.x transition period. - assert hasattr(mss, "mss") + assert hasattr(mss, "mss") # TODO(jholveck): #517 Remove compatibility path once 10.x transition period ends. assert hasattr(mss, "MSS") assert hasattr(mss, "ScreenShotError") assert hasattr(mss, "__version__") - - -def test_mssbase_compat_symbol_exists() -> None: - # TODO(jholveck): #493 Remove compatibility-only export checks after 10.x transition period. - assert hasattr(mss.base, "MSSBase") diff --git a/src/tests/test_compat_linux_api.py b/src/tests/test_compat_linux_api.py deleted file mode 100644 index 4360b1f3..00000000 --- a/src/tests/test_compat_linux_api.py +++ /dev/null @@ -1,30 +0,0 @@ -"""This is part of the MSS Python's module. -Source: https://github.com/BoboTiG/python-mss. -""" - -import platform - -import pytest - -import mss.linux - - -@pytest.mark.skipif(platform.system().lower() != "linux", reason="GNU/Linux compatibility checks") -def test_linux_10_1_documented_symbols_are_reexported() -> None: - # TODO(jholveck): #493 Drop this compatibility-only re-export check after 10.x transition period. - expected = [ - "CFUNCTIONS", - "Display", - "PLAINMASK", - "XErrorEvent", - "XFixesCursorImage", - "XImage", - "XRRCrtcInfo", - "XRRModeInfo", - "XRRScreenResources", - "XWindowAttributes", - "ZPIXMAP", - ] - - for symbol in expected: - assert hasattr(mss.linux, symbol) diff --git a/src/tests/test_setup.py b/src/tests/test_setup.py index cb629d16..d7c5e74a 100644 --- a/src/tests/test_setup.py +++ b/src/tests/test_setup.py @@ -97,7 +97,6 @@ def test_sdist() -> None: f"mss-{__version__}/src/tests/test_cls_image.py", f"mss-{__version__}/src/tests/test_compat_10_1.py", f"mss-{__version__}/src/tests/test_compat_exports.py", - f"mss-{__version__}/src/tests/test_compat_linux_api.py", f"mss-{__version__}/src/tests/test_find_monitors.py", f"mss-{__version__}/src/tests/test_get_pixels.py", f"mss-{__version__}/src/tests/test_gnu_linux.py",