From 94bfe34525696dfd53b2c2a571e911b4f829b698 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 18:58:50 +0000 Subject: [PATCH 1/2] chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.17.1 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d1dec1225..87ed441e8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: check-merge-conflict - id: debug-statements - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.10 + rev: v0.17.1 hooks: - id: ruff-check args: From bf8b114881a6434c21ebe18bf43f63ac80a82b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 20 Oct 2026 07:51:31 +0200 Subject: [PATCH 2/2] chore: modernize ruff setup --- examples/filesystem_test.py | 4 +- pyproject.toml | 86 ++++++++++++++++++------------------- test/test_dummy.py | 12 +++--- test/test_sms.py | 6 +-- test/test_time.py | 28 ++++++------ 5 files changed, 68 insertions(+), 68 deletions(-) diff --git a/examples/filesystem_test.py b/examples/filesystem_test.py index b65126c1b..925d4e8b4 100755 --- a/examples/filesystem_test.py +++ b/examples/filesystem_test.py @@ -46,7 +46,7 @@ """ import argparse -import datetime +import datetime as dt import sys from pathlib import Path @@ -132,7 +132,7 @@ def main() -> None: # ruff: ignore[too-many-branches, too-many-statements, comp file_object = Path(args.testfile) file_content = file_object.read_bytes() file_stat = file_object.stat() - ttime = datetime.datetime.fromtimestamp(file_stat[8]) + ttime = dt.datetime.fromtimestamp(file_stat[8]) file_f = { "ID_FullName": args.folder, "Name": "cgi.jpg", diff --git a/pyproject.toml b/pyproject.toml index b1e6c62d5..69fd79a6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -124,62 +124,62 @@ docstring-code-format = true extend-safe-fixes = [ "ANN", "D", - "EM101", - "EM102", - "FA102", + "f-string-in-exception", "FLY", + "future-required-type-annotation", + "raw-string-in-exception", "SIM", "TCH", "UP" ] future-annotations = true ignore = [ - "ANN001", - "ANN002", - "ANN003", - "ANN201", - "ANN202", - "ARG001", - "ARG002", + "boolean-positional-value-in-call", + "call-datetime-fromtimestamp", + "call-datetime-without-tzinfo", "COM", # CONFIG: No trailing commas - "D100", - "D101", - "D102", - "D103", - "D104", - "D107", - "D203", # CONFIG: incompatible with D211 - "D206", # CONFIG: formatter - "D212", # CONFIG: incompatible with D213 - "D401", - "DOC201", - "DOC501", - "DTZ001", - "DTZ006", - "E501", # WONTFIX: we accept long strings (rest is formatted by black) - "FBT003", - "FIX002", - "N802", - "N818", - "PERF203", # WONFIX: affects only old Python versions - "PLR2004", - "PLR6301", - "RUF012", - "S607", - "SIM115", - "SLF001", - "TD002", - "TD003", - "TRY003", - "TRY300" + "docstring-missing-exception", + "docstring-missing-returns", + "docstring-tab-indentation", # CONFIG: formatter + "error-suffix-on-exception-name", + "incorrect-blank-line-before-class", # CONFIG: incompatible with D211 + "invalid-function-name", + "line-contains-todo", + "line-too-long", # WONTFIX: we accept long strings (rest is formatted by black) + "magic-value-comparison", + "missing-return-type-private-function", + "missing-return-type-undocumented-public-function", + "missing-todo-author", + "missing-todo-link", + "missing-type-args", + "missing-type-function-argument", + "missing-type-kwargs", + "multi-line-summary-first-line", # CONFIG: incompatible with D213 + "mutable-class-default", + "no-self-use", + "non-imperative-mood", + "open-file-with-context-handler", + "private-member-access", + "raise-vanilla-args", + "start-process-with-partial-path", + "try-consider-else", + "try-except-in-loop", # WONFIX: affects only old Python versions + "undocumented-public-class", + "undocumented-public-function", + "undocumented-public-init", + "undocumented-public-method", + "undocumented-public-module", + "undocumented-public-package", + "unused-function-argument", + "unused-method-argument" ] preview = true select = ["ALL"] [tool.ruff.lint.per-file-ignores] -"examples/*.py" = ["T201"] -"setup.py" = ["T201"] -"test/*.py" = ["S101", "T201"] +"examples/*.py" = ["print"] +"setup.py" = ["print"] +"test/*.py" = ["assert", "print"] [tool.setuptools] include-package-data = false diff --git a/test/test_dummy.py b/test/test_dummy.py index ad4ef7e31..3642c1379 100644 --- a/test/test_dummy.py +++ b/test/test_dummy.py @@ -19,7 +19,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -import datetime +import datetime as dt import platform import shutil import stat @@ -102,15 +102,15 @@ def test_alarm_timezone(self) -> None: state_machine = self.get_statemachine() for timezone in ( None, - datetime.timezone.utc, - datetime.timezone(datetime.timedelta(hours=5, minutes=45)), + dt.timezone.utc, + dt.timezone(dt.timedelta(hours=5, minutes=45)), ): state_machine.SetAlarm( - datetime.time(12, 34, 56, tzinfo=timezone), Repeating=False + dt.time(12, 34, 56, tzinfo=timezone), Repeating=False ) value = state_machine.GetAlarm()["Time"] # The dummy backend explicitly resets stored alarm offsets to zero. - assert value == datetime.time(12, 34, 56, tzinfo=datetime.timezone.utc) + assert value == dt.time(12, 34, 56, tzinfo=dt.timezone.utc) def test_model(self) -> None: state_machine = self.get_statemachine() @@ -347,7 +347,7 @@ def test_emoji_folder(self) -> None: def test_addfile(self) -> None: state_machine = self.get_statemachine() file_stat = TEST_FILE.stat() - ttime = datetime.datetime.fromtimestamp(file_stat.st_mtime) + ttime = dt.datetime.fromtimestamp(file_stat.st_mtime) content = TEST_FILE.read_bytes() file_f = { "ID_FullName": "testfolder", diff --git a/test/test_sms.py b/test/test_sms.py index f2d4b9752..5564621aa 100644 --- a/test/test_sms.py +++ b/test/test_sms.py @@ -21,7 +21,7 @@ import binascii import ctypes -import datetime +import datetime as dt import os import sys import unittest @@ -492,7 +492,7 @@ def test_mms_decode(self) -> None: message = [ { "RejectDuplicates": 0, - "SMSCDateTime": datetime.datetime(2010, 7, 22, 17, 4, 11), + "SMSCDateTime": dt.datetime(2010, 7, 22, 17, 4, 11), "Class": -1, "Name": "", "InboxFolder": 0, @@ -513,7 +513,7 @@ def test_mms_decode(self) -> None: "ReplaceMessage": 0, "Coding": "8bit", "Number": "33707520030", - "DateTime": datetime.datetime(2010, 7, 1, 9, 40, 21), + "DateTime": dt.datetime(2010, 7, 1, 9, 40, 21), "DeliveryStatus": 0, "State": "UnSent", "MessageReference": 0, diff --git a/test/test_time.py b/test/test_time.py index 3ce1d2199..82cbbdb6a 100644 --- a/test/test_time.py +++ b/test/test_time.py @@ -21,14 +21,14 @@ """Timezone conversion regression tests.""" -import datetime +import datetime as dt from types import SimpleNamespace import pytest import gammu -WALL_TIME = datetime.datetime(2026, 9, 16, 12, 34, 56) +WALL_TIME = dt.datetime(2026, 9, 16, 12, 34, 56) def link_datetime(value): @@ -44,15 +44,15 @@ def link_datetime(value): "seconds", [0, 7200, -18000, 19800, -12600, 20700, 1, -1, 86399, -86399] ) def test_datetime_offset_roundtrip(seconds): - offset = datetime.timedelta(seconds=seconds) - value = WALL_TIME.replace(tzinfo=datetime.timezone(offset)) + offset = dt.timedelta(seconds=seconds) + value = WALL_TIME.replace(tzinfo=dt.timezone(offset)) result = link_datetime(value) for field in ("DateTime", "SMSCDateTime"): assert result[field].replace(tzinfo=None) == WALL_TIME assert result[field].utcoffset() == offset -class NoOffset(datetime.tzinfo): +class NoOffset(dt.tzinfo): def utcoffset(self, dt): return None @@ -68,7 +68,7 @@ def utcoffset(self, dt): def test_naive_datetime(value): result = link_datetime(value)["DateTime"] assert result.replace(tzinfo=None) == WALL_TIME - assert result.tzinfo == datetime.timezone.utc + assert result.tzinfo == dt.timezone.utc def test_missing_datetime(): @@ -87,18 +87,18 @@ def test_decode_pdu_offset(encoded_offset, seconds): pdu[14] = encoded_offset value = gammu.DecodePDU(bytes(pdu))["DateTime"] assert value.replace(tzinfo=None) == WALL_TIME - assert value.utcoffset() == datetime.timedelta(seconds=seconds) + assert value.utcoffset() == dt.timedelta(seconds=seconds) @pytest.mark.parametrize( ("offset", "error", "message"), [ (42, TypeError, "timedelta"), - (datetime.timedelta(days=1), ValueError, "24"), - (datetime.timedelta(days=-1), ValueError, "24"), - (datetime.timedelta(days=999999999), ValueError, "24"), - (datetime.timedelta(microseconds=1), ValueError, "whole number"), - (datetime.timedelta(microseconds=-1), ValueError, "whole number"), + (dt.timedelta(days=1), ValueError, "24"), + (dt.timedelta(days=-1), ValueError, "24"), + (dt.timedelta(days=999999999), ValueError, "24"), + (dt.timedelta(microseconds=1), ValueError, "whole number"), + (dt.timedelta(microseconds=-1), ValueError, "whole number"), ], ) @pytest.mark.parametrize("time_only", [False, True]) @@ -122,7 +122,7 @@ def test_invalid_offset(offset, error, message, time_only): state_machine.SetDateTime(value) -class BrokenTimezone(datetime.tzinfo): +class BrokenTimezone(dt.tzinfo): def utcoffset(self, dt): message = "offset failed" raise RuntimeError(message) @@ -132,7 +132,7 @@ def utcoffset(self, dt): def test_offset_exception(time_only): state_machine = gammu.StateMachine() if time_only: - value = datetime.time(12, 34, tzinfo=BrokenTimezone()) + value = dt.time(12, 34, tzinfo=BrokenTimezone()) with pytest.raises(RuntimeError, match="offset failed"): state_machine.SetAlarm(value, Repeating=False) else: