dodo icon indicating copy to clipboard operation
dodo copied to clipboard

Getting mypy clean again?

Open The-Compiler opened this issue 1 year ago • 0 comments

Running mypy currently reports:

dodo/settings.py:294: error: Need type annotation for "message2html_filters" (hint: "message2html_filters: list[<type>] = ...")  [var-annotated]
dodo/util.py:247: error: Argument 1 to "decode_header" has incompatible type "str | None"; expected "str"  [arg-type]
dodo/util.py:249: error: "Message[str, str]" has no attribute "get_content"; maybe "get_content_type"?  [attr-defined]
dodo/util.py:301: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice"  [index]
dodo/pgp_util.py:26: error: Cannot find implementation or library stub for module named "gnupg"  [import-not-found]
dodo/helpwindow.py:37: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/helpwindow.py:65: error: Argument 1 of "keyPressEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QKeyEvent | None"  [override]
dodo/helpwindow.py:65: note: This violates the Liskov substitution principle
dodo/helpwindow.py:65: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
dodo/thread.py:115: error: Argument 1 of "requestStarted" is incompatible with supertype "QWebEngineUrlSchemeHandler"; supertype defines the argument type as "QWebEngineUrlRequestJob | None"  [override]
dodo/thread.py:115: note: This violates the Liskov substitution principle
dodo/thread.py:115: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
dodo/thread.py:173: error: Argument 1 of "requestStarted" is incompatible with supertype "QWebEngineUrlSchemeHandler"; supertype defines the argument type as "QWebEngineUrlRequestJob | None"  [override]
dodo/thread.py:173: note: This violates the Liskov substitution principle
dodo/thread.py:173: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
dodo/thread.py:183: error: Argument 1 to "write" of "QIODevice" has incompatible type "Message[str, str] | bytes | Any"; expected "bytes | bytearray | memoryview | array[Any] | voidptr"  [arg-type]
dodo/thread.py:196: error: Function is missing a type annotation  [no-untyped-def]
dodo/thread.py:202: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
dodo/thread.py:207: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:229: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:260: error: Need type annotation for "raw_data" (hint: "raw_data: list[<type>] = ...")  [var-annotated]
dodo/thread.py:261: error: Need type annotation for "roots" (hint: "roots: list[<type>] = ...")  [var-annotated]
dodo/thread.py:268: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:268: note: Use "-> None" if function does not return a value
dodo/thread.py:277: error: Function is missing a type annotation  [no-untyped-def]
dodo/thread.py:315: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:454: error: Missing return statement  [return]
dodo/thread.py:454: error: Signature of "parent" incompatible with supertype "QAbstractItemModel"  [override]
dodo/thread.py:454: note:      Superclass:
dodo/thread.py:454: note:          @overload
dodo/thread.py:454: note:          def parent(self, child: QModelIndex) -> QModelIndex
dodo/thread.py:454: note:          @overload
dodo/thread.py:454: note:          def parent(self) -> QObject | None
dodo/thread.py:454: note:      Subclass:
dodo/thread.py:454: note:          def parent(self, child: QModelIndex = ...) -> QModelIndex
dodo/thread.py:454: error: Signature of "parent" incompatible with supertype "QObject"  [override]
dodo/thread.py:454: note:      Superclass:
dodo/thread.py:454: note:          def parent(self) -> QObject | None
dodo/thread.py:454: note:      Subclass:
dodo/thread.py:454: note:          def parent(self, child: QModelIndex = ...) -> QModelIndex
dodo/thread.py:494: error: Item "None" of "QHeaderView | None" has no attribute "setSectionResizeMode"  [union-attr]
dodo/thread.py:495: error: Item "None" of "QHeaderView | None" has no attribute "setStretchLastSection"  [union-attr]
dodo/thread.py:515: error: Item "None" of "QWebEngineSettings | None" has no attribute "setAttribute"  [union-attr]
dodo/thread.py:536: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:543: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:543: note: Use "-> None" if function does not return a value
dodo/thread.py:548: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:548: note: Use "-> None" if function does not return a value
dodo/thread.py:564: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:564: note: Use "-> None" if function does not return a value
dodo/thread.py:567: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:575: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:616: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:616: note: Use "-> None" if function does not return a value
dodo/thread.py:684: error: Function is missing a return type annotation  [no-untyped-def]
dodo/thread.py:716: error: Item "None" of "QWebEnginePage | None" has no attribute "runJavaScript"  [union-attr]
dodo/thread.py:719: error: Item "None" of "QWebEnginePage | None" has no attribute "runJavaScript"  [union-attr]
dodo/thread.py:722: error: Item "None" of "QWebEnginePage | None" has no attribute "runJavaScript"  [union-attr]
dodo/thread.py:725: error: Item "None" of "QWebEnginePage | None" has no attribute "runJavaScript"  [union-attr]
dodo/tag.py:129: error: Incompatible default for argument "child" (default has type "None", argument has type "QModelIndex")  [assignment]
dodo/tag.py:129: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
dodo/tag.py:129: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
dodo/tag.py:146: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/tag.py:153: error: Item "None" of "QAbstractItemModel | None" has no attribute "rowCount"  [union-attr]
dodo/tag.py:154: error: Item "None" of "QAbstractItemModel | None" has no attribute "index"  [union-attr]
dodo/tag.py:180: error: Item "None" of "QAbstractItemModel | None" has no attribute "index"  [union-attr]
dodo/tag.py:189: error: Item "None" of "QAbstractItemModel | None" has no attribute "index"  [union-attr]
dodo/tag.py:202: error: Item "None" of "QAbstractItemModel | None" has no attribute "rowCount"  [union-attr]
dodo/search.py:58: error: Function is missing a return type annotation  [no-untyped-def]
dodo/search.py:63: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
dodo/search.py:176: error: Incompatible default for argument "child" (default has type "None", argument has type "QModelIndex")  [assignment]
dodo/search.py:176: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
dodo/search.py:176: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
dodo/search.py:197: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/search.py:199: error: Need type annotation for "updated_threads" (hint: "updated_threads: set[<type>] = ...")  [var-annotated]
dodo/search.py:200: error: Item "None" of "QAbstractItemModel | None" has no attribute "rowCount"  [union-attr]
dodo/search.py:201: error: Item "None" of "QAbstractItemModel | None" has no attribute "index"  [union-attr]
dodo/search.py:208: error: Function is missing a return type annotation  [no-untyped-def]
dodo/search.py:208: note: Use "-> None" if function does not return a value
dodo/search.py:213: error: Function is missing a return type annotation  [no-untyped-def]
dodo/search.py:213: note: Use "-> None" if function does not return a value
dodo/search.py:216: error: Name "PyQt6" is not defined  [name-defined]
dodo/search.py:216: error: Function is missing a return type annotation  [no-untyped-def]
dodo/search.py:220: error: Function is missing a return type annotation  [no-untyped-def]
dodo/search.py:220: note: Use "-> None" if function does not return a value
dodo/search.py:269: error: Item "None" of "QAbstractItemModel | None" has no attribute "index"  [union-attr]
dodo/search.py:286: error: Item "None" of "QAbstractItemModel | None" has no attribute "index"  [union-attr]
dodo/search.py:304: error: Item "None" of "QAbstractItemModel | None" has no attribute "rowCount"  [union-attr]
dodo/search.py:311: error: Item "None" of "QScrollBar | None" has no attribute "value"  [union-attr]
dodo/search.py:311: error: Item "None" of "QScrollBar | None" has no attribute "minimum"  [union-attr]
dodo/search.py:316: error: Item "None" of "QScrollBar | None" has no attribute "triggerAction"  [union-attr]
dodo/search.py:323: error: Item "None" of "QScrollBar | None" has no attribute "value"  [union-attr]
dodo/search.py:323: error: Item "None" of "QScrollBar | None" has no attribute "maximum"  [union-attr]
dodo/search.py:328: error: Item "None" of "QScrollBar | None" has no attribute "triggerAction"  [union-attr]
dodo/panel.py:61: error: Item "None" of "QLayout | None" has no attribute "setContentsMargins"  [union-attr]
dodo/panel.py:81: error: Name "PyQt6" is not defined  [name-defined]
dodo/panel.py:81: error: Function is missing a return type annotation  [no-untyped-def]
dodo/panel.py:140: error: Argument 1 of "keyPressEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QKeyEvent | None"  [override]
dodo/panel.py:140: note: This violates the Liskov substitution principle
dodo/panel.py:140: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
dodo/mainwindow.py:46: error: Item "None" of "QLayout | None" has no attribute "setContentsMargins"  [union-attr]
dodo/mainwindow.py:47: error: Item "None" of "QLayout | None" has no attribute "setSpacing"  [union-attr]
dodo/mainwindow.py:56: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/mainwindow.py:77: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/mainwindow.py:78: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/mainwindow.py:80: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/mainwindow.py:83: error: Argument 1 of "closeEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QCloseEvent | None"  [override]
dodo/mainwindow.py:83: note: This violates the Liskov substitution principle
dodo/mainwindow.py:83: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
dodo/compose.py:49: error: Cannot find implementation or library stub for module named "gnupg"  [import-not-found]
dodo/compose.py:49: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
dodo/compose.py:69: error: Item "None" of "QLayout | None" has no attribute "addWidget"  [union-attr]
dodo/compose.py:249: error: "None" has no attribute "format"  [attr-defined]
dodo/commandbar.py:44: error: Cannot assign to a method  [method-assign]
dodo/commandbar.py:46: error: Function is missing a return type annotation  [no-untyped-def]
dodo/commandbar.py:61: error: Function is missing a return type annotation  [no-untyped-def]
dodo/commandbar.py:73: error: "Callable[[], QCompleter | None]" has no attribute "setCompletionPrefix"  [attr-defined]
dodo/commandbar.py:75: error: "Callable[[], QCompleter | None]" has no attribute "popup"  [attr-defined]
dodo/commandbar.py:76: error: "Callable[[], QCompleter | None]" has no attribute "completionModel"  [attr-defined]
dodo/commandbar.py:77: error: "Callable[[], QCompleter | None]" has no attribute "complete"  [attr-defined]
dodo/commandbar.py:79: error: Function is missing a type annotation  [no-untyped-def]
dodo/commandbar.py:129: error: "Callable[[], QCompleter | None]" has no attribute "popup"  [attr-defined]
dodo/commandbar.py:168: error: Argument 1 of "keyPressEvent" is incompatible with supertype "QLineEdit"; supertype defines the argument type as "QKeyEvent | None"  [override]
dodo/commandbar.py:168: note: This violates the Liskov substitution principle
dodo/commandbar.py:168: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
dodo/commandbar.py:168: error: Argument 1 of "keyPressEvent" is incompatible with supertype "QWidget"; supertype defines the argument type as "QKeyEvent | None"  [override]
dodo/commandbar.py:178: error: "Callable[[], QCompleter | None]" has no attribute "popup"  [attr-defined]
dodo/app.py:49: error: Incompatible default for argument "parent" (default has type "None", argument has type "QObject")  [assignment]
dodo/app.py:49: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
dodo/app.py:49: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
dodo/app.py:95: error: Need type annotation for "panel_history" (hint: "panel_history: list[<type>] = ...")  [var-annotated]
dodo/app.py:122: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
dodo/app.py:289: error: Function is missing a return type annotation  [no-untyped-def]
Found 95 errors in 12 files (checked 16 source files)

(plus another 52 errors with strict=True added to the config)

I have some experience with getting those fixed (especially in a PyQt codebase) - would it be a welcome addition to take care of those, and then ideally run mypy on CI via GitHub Actions to avoid regressions?

The-Compiler avatar Sep 12 '24 08:09 The-Compiler