Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2280

Typings miss type arguments for generic class PathLike

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.7.0, 6.8.0
    • 6.4.3
    • Type hints
    • None
    • 0e62a3d99 (dev), 4ccf122a4 (6.7)

    Description

      Type checker like pyright return an error on function taking an os.PathLike argument

      QtCore.QUrl.fromLocalFile("/tmp/testme")
      => Type of "fromLocalFile" is partially unknown
        Type of "fromLocalFile" is "(localfile: str | bytes | PathLike[Unknown]) -> QUrl"
      

      This is because os.PathLike typing is defined with a generic class in typeshed

      To fix the issue the Qt6 stubs should use os.PathLike[str].

      Example in QtCore.pyi:

      # replace this
      def fromLocalFile(localfile: Union[str, bytes, os.PathLike]) -> PySide6.QtCore.QUrl: ...
      
      # by this
      def fromLocalFile(localfile: Union[str, bytes, os.PathLike[str]]) -> PySide6.QtCore.QUrl: ...
      

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            rems Rémy Cocole
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes