0

I create my .ui files with QT Designer and convert them to a python file using the pyside6-uic ... command. Each time I load such an `auto-generated' python file via :

class MyCrazyTestDialog(QDialog):

    def __init__(self) -> None:

        super().__init__()

        self.ui = Ui_MyCrazyTestDialog()
        self.ui.setupUi(self)

the line self.ui.setupUi(self) will generate the mypy error:

Mypy: Call to untyped function "setupUi" in typed context [no-untyped-call]

I have tried several ways to exclude all auto-generated files from the mypy search. But had no success. The obvious solution with self.ui.setupUi(self) # type: ignore does not work either, because it will complain about calling an untyped function in the type environment for every line that uses self.ui...

I have already installed the unofficial pyside6 stubs from here, which helped with mypy errors for the self.translate qt code, but it does not help here.

Does anyone know how I can configure my mypy setup so that it will ignore calls to the auto-generated files?

sebwr
  • 113
  • 1
  • 10
  • Does this answer your question? [How can mypy ignore a single line in a source file?](https://stackoverflow.com/questions/49220022/how-can-mypy-ignore-a-single-line-in-a-source-file) – relent95 Jul 16 '23 at 01:34
  • You need to add "# type: ignore" to only three lines, one for calling the ```Ui_MyCrazyTestDialog()```, one for calling the ```setupUi()```, and one for calling the ```retranslateUi()```. – relent95 Jul 16 '23 at 02:11
  • What about disabling [disallow-untyped-calls](https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-no-untyped-functions-are-called-no-untyped-call) option? – Alireza Roshanzamir Jul 17 '23 at 13:25

0 Answers0