Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QGIS Python module type stubs broken by empty enums and reserved name #46240

Closed
2 tasks done
komima opened this issue Nov 26, 2021 · 0 comments · Fixed by #46255
Closed
2 tasks done

QGIS Python module type stubs broken by empty enums and reserved name #46240

komima opened this issue Nov 26, 2021 · 0 comments · Fixed by #46255
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@komima
Copy link
Contributor

komima commented Nov 26, 2021

What is the bug or the crash?

QGIS Python module type stub .pyi files have errors, and types are not available in IDE/mypy/pyright contexts.

  1. Empty enums are output from QgsProcessingContext and QgsModelComponentGraphicItem, and the syntax is not valid:
    image

  2. self is used as parameter name in QgsVectorDataProvider (and I assume in all subclasses if that is relevant, for example in QgsPostgresProvider), and that conflicts with the instance parameter in Python method signature:
    image

Steps to reproduce the issue

  • Use any python interpreter to create a new venv and install mypy
  • Set PYTHONPATH env var to point at the installed qgis python module
  • Use stubgen to generate stubs with stubgen -m qgis.core or stubgen -m qgis.gui
  • Observe that previously shown errors occur when parsing existing .pyis

Versions

QGIS 3.22.0 on Windows 10 (from osgeo v2 network installer qgis-package)

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

  • QGIS .pyis were added (at least to Windows packaging) based on Generate type stub files for python API #41264
  • Unrelated to this specific bug (but contributing to missing types), PyQt5 .pyis are missing on Windows for now (ticket for that issue)
  • Lots of enum changes happened lately?
  • Update from 3.16/py3.7 to 3.22/py3.9 caused this issue to appear, previous stubs include the empty enums as they probably should appear as class Flag(int): .... Those were taken from docker image and are Generated by SIP 4.19.21, current install stubs are Generated by SIP 6.1.1, so SIP version might also be a relevant change.
@komima komima added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Nov 26, 2021
@nyalldawson nyalldawson self-assigned this Nov 28, 2021
nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants