From 99637cc430d33abd5a8af194742e809417fe19be Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 27 Mar 2025 16:12:25 +0100 Subject: [PATCH] fix(PyQt5toPyQt6): check if object has an attribute id Error fixed running the migration script on a certain plugin: ```python Traceback (most recent call last): File "/usr/local/bin/pyqt5_to_pyqt6.py", line 892, in raise SystemExit(main()) ^^^^^^ File "/usr/local/bin/pyqt5_to_pyqt6.py", line 887, in main ret |= fix_file(filename, not args.qgis3_incompatible_changes, dry_run) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/bin/pyqt5_to_pyqt6.py", line 461, in fix_file visit_call(node, parent) File "/usr/local/bin/pyqt5_to_pyqt6.py", line 338, in visit_call and _node.args[0].func.id == "QDate" ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Attribute' object has no attribute 'id' ``` --- scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py b/scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py index 0f7e2e33e32..ea5b5953db2 100755 --- a/scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py +++ b/scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py @@ -335,6 +335,7 @@ def fix_file(filename: str, qgis3_compat: bool, dry_run: bool = False) -> int: elif ( len(_node.args) == 1 and isinstance(_node.args[0], ast.Call) + and hasattr(_node.args[0].func, "id") and _node.args[0].func.id == "QDate" ): # QDateTime(QDate(..)) doesn't work anymore,