diff --git a/docs/changelog.rst b/docs/changelog.rst index 4444add..80d92c7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,13 @@ Changelog ========= +v3.6.0 (2022-02-17) +------------------- +- Fix pylint warning "Abstract class :class:`WindowsFileLock ` with abstract methods instantiated" + :pr:`135` - by :user:`vonschultz` +- Fix pylint warning "Abstract class :class:`UnixFileLock ` with abstract methods instantiated" + :pr:`135` - by :user:`vonschultz` + v3.5.1 (2022-02-16) ------------------- - Use ``time.monotonic`` instead of ``time.time`` for calculating timeouts. diff --git a/src/filelock/_unix.py b/src/filelock/_unix.py index e988380..03b612c 100644 --- a/src/filelock/_unix.py +++ b/src/filelock/_unix.py @@ -2,7 +2,6 @@ import os import sys -from abc import ABC from typing import cast from ._api import BaseFileLock @@ -11,9 +10,15 @@ has_fcntl = False if sys.platform == "win32": # pragma: win32 cover - class UnixFileLock(BaseFileLock, ABC): + class UnixFileLock(BaseFileLock): """Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.""" + def _acquire(self) -> None: + raise NotImplementedError + + def _release(self) -> None: + raise NotImplementedError + else: # pragma: win32 no cover try: import fcntl diff --git a/src/filelock/_windows.py b/src/filelock/_windows.py index affd93e..60e68cb 100644 --- a/src/filelock/_windows.py +++ b/src/filelock/_windows.py @@ -2,7 +2,6 @@ import os import sys -from abc import ABC from errno import ENOENT from typing import cast @@ -49,9 +48,15 @@ def _release(self) -> None: else: # pragma: win32 no cover - class WindowsFileLock(BaseFileLock, ABC): + class WindowsFileLock(BaseFileLock): """Uses the :func:`msvcrt.locking` function to hard lock the lock file on windows systems.""" + def _acquire(self) -> None: + raise NotImplementedError + + def _release(self) -> None: + raise NotImplementedError + __all__ = [ "WindowsFileLock", diff --git a/tests/test_filelock.py b/tests/test_filelock.py index bce9e1e..f439ff6 100644 --- a/tests/test_filelock.py +++ b/tests/test_filelock.py @@ -1,5 +1,6 @@ from __future__ import annotations +import inspect import logging import sys import threading @@ -13,7 +14,7 @@ import pytest from _pytest.logging import LogCaptureFixture -from filelock import BaseFileLock, FileLock, SoftFileLock, Timeout +from filelock import BaseFileLock, FileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock @pytest.mark.parametrize( @@ -382,3 +383,17 @@ def decorated_method() -> None: assert not lock.is_locked decorated_method() assert not lock.is_locked + + +def test_wrong_platform(tmp_path: Path) -> None: + assert not inspect.isabstract(UnixFileLock) + assert not inspect.isabstract(WindowsFileLock) + assert inspect.isabstract(BaseFileLock) + + lock_type = UnixFileLock if sys.platform == "win32" else WindowsFileLock + lock = lock_type(str(tmp_path / "lockfile")) + + with pytest.raises(NotImplementedError): + lock.acquire() + with pytest.raises(NotImplementedError): + lock._release() diff --git a/whitelist.txt b/whitelist.txt index 6882459..7eeb6b9 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -15,6 +15,7 @@ fmt fspath intersphinx intervall +isabstract iwgrp iwoth iwusr