From 3668f12822226ee1acb2b940e1cad2454487269d Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 29 Jan 2025 13:29:16 +0100 Subject: [PATCH] py: Enable mypy checking with pre-commit --- .mypy.ini | 10 ++++++++++ .pre-commit-config.yaml | 6 ++++++ tests/.mypy.ini | 15 --------------- tests/templates/access.py | 1 + tests/templates/account.py | 1 + tests/templates/appchooser.py | 1 + tests/templates/background.py | 1 + tests/templates/clipboard.py | 1 + tests/templates/dynamiclauncher.py | 1 + tests/templates/email.py | 1 + tests/templates/filechooser.py | 1 + tests/templates/geoclue2.py | 1 + tests/templates/globalshortcuts.py | 1 + tests/templates/inhibit.py | 1 + tests/templates/inputcapture.py | 1 + tests/templates/lockdown.py | 1 + tests/templates/notification.py | 1 + tests/templates/print.py | 1 + tests/templates/remotedesktop.py | 1 + tests/templates/screenshot.py | 1 + tests/templates/settings.py | 1 + tests/templates/usb.py | 1 + tests/templates/wallpaper.py | 1 + 23 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 .mypy.ini delete mode 100644 tests/.mypy.ini diff --git a/.mypy.ini b/.mypy.ini new file mode 100644 index 000000000..7dfe78d99 --- /dev/null +++ b/.mypy.ini @@ -0,0 +1,10 @@ +[mypy] +warn_unused_configs = True +check_untyped_defs=True + +[mypy-gi.*] +ignore_missing_imports = True +[mypy-dbus.*] +ignore_missing_imports = True +[mypy-dbusmock.*] +ignore_missing_imports = True \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9752aedb3..b8796dcab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,3 +8,9 @@ repos: # Run the formatter. - id: ruff-format args: [ --check ] +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.14.1 + hooks: + - id: mypy + additional_dependencies: + - pytest \ No newline at end of file diff --git a/tests/.mypy.ini b/tests/.mypy.ini deleted file mode 100644 index 07afc4a11..000000000 --- a/tests/.mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -warn_unused_configs = True -check_untyped_defs=True -files=. -exclude = (?x)( - templates/.*.py # template files are a bit special - |test_document_fuse.py$ # has issues with typing - ) - -[mypy-gi.*] -ignore_missing_imports = True -[mypy-dbus.*] -ignore_missing_imports = True -[mypy-dbusmock.*] -ignore_missing_imports = True diff --git a/tests/templates/access.py b/tests/templates/access.py index fba270edf..4c198ac13 100644 --- a/tests/templates/access.py +++ b/tests/templates/access.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/account.py b/tests/templates/account.py index b2642af3e..8db301046 100644 --- a/tests/templates/account.py +++ b/tests/templates/account.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/appchooser.py b/tests/templates/appchooser.py index 4be4f6943..2a5f05699 100644 --- a/tests/templates/appchooser.py +++ b/tests/templates/appchooser.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/background.py b/tests/templates/background.py index 11e44351a..f17bb1e3f 100644 --- a/tests/templates/background.py +++ b/tests/templates/background.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import init_logger diff --git a/tests/templates/clipboard.py b/tests/templates/clipboard.py index 5a57267c2..170cf8e08 100644 --- a/tests/templates/clipboard.py +++ b/tests/templates/clipboard.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import init_logger diff --git a/tests/templates/dynamiclauncher.py b/tests/templates/dynamiclauncher.py index e8cd08620..96ac752a2 100644 --- a/tests/templates/dynamiclauncher.py +++ b/tests/templates/dynamiclauncher.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/email.py b/tests/templates/email.py index 7f786a25a..5d56b1323 100644 --- a/tests/templates/email.py +++ b/tests/templates/email.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/filechooser.py b/tests/templates/filechooser.py index 49439d119..f9ef6d726 100644 --- a/tests/templates/filechooser.py +++ b/tests/templates/filechooser.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/geoclue2.py b/tests/templates/geoclue2.py index 40d7ebb14..c7988a400 100644 --- a/tests/templates/geoclue2.py +++ b/tests/templates/geoclue2.py @@ -1,4 +1,5 @@ # SPDX-License-Identifier: LGPL-2.1-or-later +# mypy: disable-error-code="misc" from tests.templates import init_logger diff --git a/tests/templates/globalshortcuts.py b/tests/templates/globalshortcuts.py index f047fc452..d73849295 100644 --- a/tests/templates/globalshortcuts.py +++ b/tests/templates/globalshortcuts.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest, ImplSession diff --git a/tests/templates/inhibit.py b/tests/templates/inhibit.py index ce107cdcd..364511803 100644 --- a/tests/templates/inhibit.py +++ b/tests/templates/inhibit.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest, ImplSession diff --git a/tests/templates/inputcapture.py b/tests/templates/inputcapture.py index fc9022cdc..d6ba7b8d3 100644 --- a/tests/templates/inputcapture.py +++ b/tests/templates/inputcapture.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger diff --git a/tests/templates/lockdown.py b/tests/templates/lockdown.py index f5d124046..adcf9431a 100644 --- a/tests/templates/lockdown.py +++ b/tests/templates/lockdown.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import init_logger diff --git a/tests/templates/notification.py b/tests/templates/notification.py index 9e1c8ba3a..730061cfc 100644 --- a/tests/templates/notification.py +++ b/tests/templates/notification.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import init_logger diff --git a/tests/templates/print.py b/tests/templates/print.py index c10a7d5bd..c3475f51b 100644 --- a/tests/templates/print.py +++ b/tests/templates/print.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/remotedesktop.py b/tests/templates/remotedesktop.py index 972f6c55d..3030fb2aa 100644 --- a/tests/templates/remotedesktop.py +++ b/tests/templates/remotedesktop.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest, ImplSession diff --git a/tests/templates/screenshot.py b/tests/templates/screenshot.py index 7e0212667..16101751f 100644 --- a/tests/templates/screenshot.py +++ b/tests/templates/screenshot.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/settings.py b/tests/templates/settings.py index 339aeaabc..7a4077301 100644 --- a/tests/templates/settings.py +++ b/tests/templates/settings.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import init_logger diff --git a/tests/templates/usb.py b/tests/templates/usb.py index 84aed8243..129020052 100644 --- a/tests/templates/usb.py +++ b/tests/templates/usb.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest diff --git a/tests/templates/wallpaper.py b/tests/templates/wallpaper.py index a73e4f287..0b813394d 100644 --- a/tests/templates/wallpaper.py +++ b/tests/templates/wallpaper.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # # This file is formatted with Python Black +# mypy: disable-error-code="misc" from tests.templates import Response, init_logger, ImplRequest