Skip to content

Fix type hint linter issues #86

@GoToLoop

Description

@GoToLoop

Like the original "thonnycontrib/thonny-py5mode/install_jdk.py", most thonny-py5mode files are littered w/ linter type warnings:

"thonnycontrib/thonny-py5mode/init.py":

"get_filename" is not a known attribute of "None"
Argument of type "Editor | None" cannot be assigned to parameter "self" of type "Editor" in function "save_file"
  Type "Editor | None" is not assignable to type "Editor"
    "None" is not assignable to "Editor"
"get_filename" is not a known attribute of "None"
"save_file" is not a known attribute of "None"
"submodule_search_locations" is not a known attribute of "None"
Object of type "None" is not subscriptable
"run_sketch" is possibly unbound
Object of type "None" is not subscriptable
"submodule_search_locations" is not a known attribute of "None"
Cannot assign to attribute "_original_execute_current" for class "type[Runner]"
  Attribute "_original_execute_current" is unknown
Cannot access attribute "_original_execute_current" for class "type[Runner]"
  Attribute "_original_execute_current" is unknown
"get_filename" is not a known attribute of "None"
Argument of type "Editor | None" cannot be assigned to parameter "self" of type "Editor" in function "save_file"
  Type "Editor | None" is not assignable to type "Editor"
    "None" is not assignable to "Editor"
"get_filename" is not a known attribute of "None"
"save_file" is not a known attribute of "None"
"_load_file" is not a known attribute of "None"
No parameter named "master"
Cannot access attribute "_original_handle_program_output" for class "type[BaseShellText]"
  Attribute "_original_handle_program_output" is unknown
"get_filename" is not a known attribute of "None"
No overloads for "dirname" match the provided arguments
Argument of type "Unknown | str | None" cannot be assigned to parameter "p" of type "AnyOrLiteralStr@dirname" in function "dirname"
  Type "Unknown | str | None" is not assignable to constrained type variable "AnyOrLiteralStr"
Argument of type "() -> bool" cannot be assigned to parameter "handler" of type "(() -> None) | None" in function "add_command"
  Type "() -> bool" is not assignable to type "(() -> None) | None"
    Type "() -> bool" is not assignable to type "() -> None"
      Function return type "bool" is incompatible with type "None"
        "bool" is not assignable to "None"
    "FunctionType" is not assignable to "None"
Argument of type "() -> bool" cannot be assigned to parameter "handler" of type "(() -> None) | None" in function "add_command"
  Type "() -> bool" is not assignable to type "(() -> None) | None"
    Type "() -> bool" is not assignable to type "() -> None"
      Function return type "bool" is incompatible with type "None"
        "bool" is not assignable to "None"
    "FunctionType" is not assignable to "None"
Cannot assign to attribute "_original_handle_program_output" for class "type[BaseShellText]"
  Attribute "_original_handle_program_output" is unknown

"thonnycontrib/thonny-py5mode/about_plugin.py":

Type "Literal['(32-bit)']" is not assignable to return type "None"
  "Literal['(32-bit)']" is not assignable to "None"
Type "Literal['(64-bit)']" is not assignable to return type "None"
  "Literal['(64-bit)']" is not assignable to "None"
Type "Literal['']" is not assignable to return type "None"
  "Literal['']" is not assignable to "None"
"font" is not a known attribute of module "tkinter"
"font" is not a known attribute of module "tkinter"
Import "distro" could not be resolved
Operator "+" not supported for types "Literal[' ']" and "None"
Operator "+" not supported for types "str" and "None"

"thonnycontrib/backend/py5_imported_mode_backend.py":

Import "thonny.plugins.cpython.cpython_backend" could not be resolved
Cannot access attribute "source" for class "InlineCommand"
  Attribute "source" is unknown
Cannot access attribute "row" for class "InlineCommand"
  Attribute "row" is unknown
Cannot access attribute "column" for class "InlineCommand"
  Attribute "column" is unknown
Cannot access attribute "filename" for class "InlineCommand"
  Attribute "filename" is unknown
"jedi_utils" is possibly unbound
"get_sys_path_directory_containg_plugins" is possibly unbound
"_original_editor_autocomplete" is not a known attribute of "None"
Cannot access attribute "_original_editor_autocomplete" for class "MainCPythonBackend*"
  Attribute "_original_editor_autocomplete" is unknown
Type "dict[str, Unknown] | Unknown" is not assignable to return type "InlineResponse"
  Type "dict[str, Unknown] | Unknown" is not assignable to type "InlineResponse"
    "dict[str, Unknown]" is not assignable to "InlineResponse"
Cannot assign to attribute "_original_editor_autocomplete" for class "type[MainCPythonBackend]"
  Attribute "_original_editor_autocomplete" is unknown
Cannot assign to attribute "_cmd_editor_autocomplete" for class "type[MainCPythonBackend]"
  Type "(self: MainCPythonBackend | Unknown, cmd: InlineCommand) -> InlineResponse" is not assignable to type "(self: MainCPythonBackend, cmd: Unknown) -> dict[str, List[CompletionInfo] | str | None]"
    Function return type "InlineResponse" is incompatible with type "dict[str, List[CompletionInfo] | str | None]"
      "InlineResponse" is not assignable to "dict[str, List[CompletionInfo] | str | None]"

"thonnycontrib/kyanite_theme_syntax/init.py":

Type "dict[str, dict[str, str | int | bool] | dict[str, str | None]]" is not assignable to return type "SyntaxThemeSettings"
  Type "None" is not assignable to type "str | int | bool"
    "None" is not assignable to "str"
    "None" is not assignable to "int"
    "None" is not assignable to "bool"

Files inside "thonny-py5mode/py5colorpicker/tkcolorpicker/" have even worse issues; but I believe they should go to a separate repo.

Should we try to fix them all or at least lower that number of linter errors?

Gonna do some attempts now and see how far I can get.

P.S.: Linter errors from extension BasedPyright on VSCodium w/ Python 3.10.18 venv containing Thonny + Py5Mode plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions