diff --git a/screen_brightness_control/__init__.py b/screen_brightness_control/__init__.py index b46dc73..accd101 100644 --- a/screen_brightness_control/__init__.py +++ b/screen_brightness_control/__init__.py @@ -4,7 +4,6 @@ import time import traceback from dataclasses import dataclass, field -from types import ModuleType from typing import Callable, Any, Dict, List, Optional, Tuple, Type, Union, FrozenSet, ClassVar from ._version import __author__, __version__ # noqa: F401 from .exceptions import NoValidDisplayError, format_exc @@ -320,7 +319,7 @@ def get_methods(name: Optional[str] = None) -> Dict[str, Type[BrightnessMethod]] print('Associated monitors:', sbc.list_monitors(method=method_name)) ``` ''' - methods = {i.__name__.lower(): i for i in _OS_METHODS} + methods: Dict[str, type[BrightnessMethod]] = {i.__name__.lower(): i for i in _OS_MODULE.METHODS} if name is None: return methods @@ -366,7 +365,7 @@ class Display(): '''The serial number of the display or (if serial is not available) an ID assigned by the OS''' _logger: logging.Logger = field(init=False, repr=False) - _fade_thread_dict: ClassVar[Dict[FrozenSet[Tuple[Any, Any]], threading.Thread]] = {} + _fade_thread_dict: ClassVar[Dict[FrozenSet[Any], threading.Thread]] = {} '''A dictionary mapping display identifiers to latest fade threads for stopping fades.''' def __post_init__(self): @@ -761,16 +760,12 @@ def __brightness( raise ScreenBrightnessError(msg) -_OS_MODULE: ModuleType -_OS_METHODS: Tuple[Type[BrightnessMethod], ...] if platform.system() == 'Windows': from . import windows _OS_MODULE = windows - _OS_METHODS = windows.METHODS elif platform.system() == 'Linux': from . import linux _OS_MODULE = linux - _OS_METHODS = linux.METHODS else: _logger.warning( f'package imported on unsupported platform ({platform.system()})') diff --git a/tests/conftest.py b/tests/conftest.py index eee1f11..f023122 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,7 +17,6 @@ @pytest.fixture(autouse=True) def mock_os_module(monkeypatch: pytest.MonkeyPatch): monkeypatch.setattr(sbc, '_OS_MODULE', os_module_mock) - monkeypatch.setattr(sbc, '_OS_METHODS', os_module_mock.METHODS) return os_module_mock diff --git a/tests/test_init.py b/tests/test_init.py index 6fc153a..a683ab1 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -196,7 +196,7 @@ def test_returns_dict_of_brightness_methods(self, subtests): methods = sbc.get_methods() assert isinstance(methods, dict) # check all methods included - assert tuple(methods.values()) == sbc._OS_METHODS + assert tuple(methods.values()) == sbc._OS_MODULE.METHODS # check names match up for name, method_class in methods.items(): with subtests.test(method=name): @@ -206,7 +206,7 @@ def test_returns_dict_of_brightness_methods(self, subtests): class TestNameKwarg: def test_non_str_raises_type_error(self): with pytest.raises(TypeError, match=r'name must be of type str.*'): - sbc.get_methods(sbc._OS_METHODS[0]) # type: ignore + sbc.get_methods(sbc._OS_MODULE.METHODS[0]) # type: ignore def test_raises_value_error_on_invalid_lookup(self): with pytest.raises(ValueError, match=r'invalid method.*'):