[Python] How to suppress Pyright warning message in VSCodium [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have VSCodium installed on Linux Mint Mate 22.1 with tthe Ruff and Pyright extensions. Given this program snippet:

    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk


    This warning message is displayed: "Gtk" is unknown import symbol referencing line 3.

    I want to suppress the message, as the program works fine. I got this suggested fix from the Brave browser's LEO ChatGPT (file pyrightconfig.json in the same folder as the python script):

    {
    "exclude": ["node_modules", "bower_components", "jspm_packages"],
    "reportMissingImports": false,
    "reportUnknownIdentifier": false,
    "reportUnknownVariableInType": false,
    "reportUnknownModule": false,
    "include": ["src", "tests"],
    "ignore": ["gi/repository/Gtk"]
    }


    It didn't work, so I tried

    "ignore": ["gi.repository.Gtk"]

    and

    "ignore": ["gi.repository"]

    neither of which worked, either. What needs to be changed to suppress the message?

    Related question: What do the "include" and "exclude" statements refer to?

    Continue reading...

Compartilhe esta Página