diff --git a/dissect/util/cpio.py b/dissect/util/cpio.py index f92ea97..404878b 100644 --- a/dissect/util/cpio.py +++ b/dissect/util/cpio.py @@ -214,7 +214,7 @@ def _swap16(value: int) -> int: return ((value & 0xFF) << 8) | (value >> 8) -def CpioFile(*args, **kwargs) -> tarfile.TarFile: +def CpioFile(*args, **kwargs) -> tarfile.TarFile: # noqa: N802 """Utility wrapper around ``tarfile.TarFile`` to easily open cpio archives.""" kwargs.setdefault("format", FORMAT_CPIO_UNKNOWN) return tarfile.TarFile(*args, **kwargs, tarinfo=CpioInfo) diff --git a/dissect/util/feature.py b/dissect/util/feature.py index 8dac3d7..6d5f0c4 100644 --- a/dissect/util/feature.py +++ b/dissect/util/feature.py @@ -20,7 +20,7 @@ class Feature(Enum): DISSECT_FEATURES_ENV = "DISSECT_FEATURES" -class FeatureException(RuntimeError): +class FeatureError(RuntimeError): pass @@ -60,7 +60,7 @@ def my_func( ... ) -> ... if alternative is None: def alternative() -> NoReturn: - raise FeatureException( + raise FeatureError( "\n".join( [ "Feature disabled.", diff --git a/dissect/util/ts.py b/dissect/util/ts.py index 753d4f0..cad6f28 100644 --- a/dissect/util/ts.py +++ b/dissect/util/ts.py @@ -234,6 +234,9 @@ def uuid1timestamp(ts: int) -> datetime: return _calculate_timestamp(float(ts) * 1e-7 - 12219292800) +DOS_EPOCH_YEAR = 1980 + + def dostimestamp(ts: int, centiseconds: int = 0, swap: bool = False) -> datetime: """Converts MS-DOS timestamps to naive datetime objects. @@ -243,15 +246,13 @@ def dostimestamp(ts: int, centiseconds: int = 0, swap: bool = False) -> datetime According to http://www.vsft.com/hal/dostime.htm Args: - timestap: MS-DOS timestamp - centisecond: Optional ExFAT centisecond offset. Yes centisecond... + ts: MS-DOS timestamp + centiseconds: Optional ExFAT centisecond offset. Yes centisecond... swap: Optional swap flag if date and time bytes are swapped. Returns: Datetime object from the passed timestamp. """ - DOS_EPOCH_YEAR = 1980 - # MS-DOS Date Time Format is actually 2 UINT16_T's first 16 bits are the time, second 16 bits are date # the year is an offset of the MS-DOS epoch year, which is 1980 diff --git a/dissect/util/xmemoryview.py b/dissect/util/xmemoryview.py index f5dfc78..624b1c5 100644 --- a/dissect/util/xmemoryview.py +++ b/dissect/util/xmemoryview.py @@ -51,7 +51,7 @@ def xmemoryview(view: bytes, format: str) -> memoryview | _xmemoryview: return _xmemoryview(view, format) -class _xmemoryview: +class _xmemoryview: # noqa: N801 """Wrapper for memoryview that converts between host and a different destination endianness. Args: diff --git a/pyproject.toml b/pyproject.toml index c1dae60..0984e4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,9 +57,11 @@ select = [ "E", "W", "I", + "N", "UP", "YTT", "ANN", + "S", "B", "C4", "DTZ", @@ -86,10 +88,11 @@ select = [ "FURB", "RUF", ] -ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM105", "TRY003"] +ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "S110", "SIM105", "TRY003"] [tool.ruff.lint.per-file-ignores] "tests/docs/**" = ["INP001"] +"tests/**" = ["S101"] [tool.ruff.lint.isort] known-first-party = ["dissect.util"] diff --git a/tests/test_plist.py b/tests/test_plist.py index 60df5c5..631bb93 100644 --- a/tests/test_plist.py +++ b/tests/test_plist.py @@ -1,7 +1,7 @@ import datetime -import plistlib import sys import uuid +from plistlib import UID from unittest.mock import patch import pytest @@ -11,8 +11,6 @@ @pytest.mark.skipif(sys.version_info < (3, 8), reason="requires python3.8 or higher") def test_plist_nskeyedarchiver() -> None: - UID = plistlib.UID - data = { "$version": 100000, "$archiver": "NSKeyedArchiver",