Skip to main content

PEP561 stub files for the QGIS Python wrapper

Project description

Type Stubs for QGIS

This package defines Python stub files (.pyi) for the PyQGIS wrapper module available in QGIS.

Overview

The bulk of the qgis module is a SIP-generated wrapper over a C++ source, which cannot be introspected by the user or development utilities.

Python type stubs are a declaration-only replication of the C/C++ endpoints that can be parsed by IDEs, linters, or static type checkers to provide the same functionality available for regular Python sources.

While type stubs are primarily intended for use with static type checkers like Mypy or Pylance, they are also used by some linters like pylint and will silence error messages like import-error or no-name-in-module.

Installation

qgis-stubs can be installed through pip:

$ python -m pip install qgis-stubs

Alternatively, you can clone and install them straight from this repository:

$ python -m pip install git+https://github.com/leonhard-s/qgis-stubs.git

Limitations

This project is in early stages and does not yet cover the full interface. This is largely due to QGIS doing a lot of monkey-patching that are not automatically replicated in the stub files.

Here is a likely incomplete list of known limitations/omissions:

  • Compatibility fallbacks and non-standard attributes may be missing (as they are monkey patched).

  • Most methods do not contain docstrings (these too are monkey-patched).

  • None of the types and utilities defined in the core.additions namespace are available as they mostly serve to allow for more monkey-patching.

  • QGIS enumerators clutter the parent namespace, which can lead to name collisions.

    For example: The value QgsAggregateMappingModel.ColumnDataIndex.Aggregate instead escalates to QgsAggregateMappingModel.Aggregate, which is subsequently overwritten by an inner class of the same qualified name.

    Such names are inaccessible in the stubs and possibly even at runtime. I did not yet have time to investigate further.

Contributing

If you encounter any issues such as missing or incorrect hints or other unexpected behaviour, please do not hesitate to create an issue or start hacking away.

The current version of this package was created with copious amounts of RegEx-based edits and refactoring tools, though I did end up manually merging files and adding missing types a lot.

If this utility is useful to you, please let me know and I will happily look into automating the entire workflow to keep this package synchronised with QGIS releases.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qgis-stubs-0.1.0.tar.gz (281.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qgis_stubs-0.1.0-py3-none-any.whl (287.1 kB view details)

Uploaded Python 3

File details

Details for the file qgis-stubs-0.1.0.tar.gz.

File metadata

  • Download URL: qgis-stubs-0.1.0.tar.gz
  • Upload date:
  • Size: 281.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5

File hashes

Hashes for qgis-stubs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0a5e3daed426e84df2c1d8aa974e90dd03503387047114d1bd2146c1a1a153b
MD5 5e242f266a5e17aa47eb88e00029a561
BLAKE2b-256 2e05d66b5cb53edda94cf7cb2be37d2db9cf61080e705d0abb7d4f7709774afb

See more details on using hashes here.

File details

Details for the file qgis_stubs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qgis_stubs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 287.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5

File hashes

Hashes for qgis_stubs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dd918fbc60d5787106d4ce7acabe30dfa917be5b14ae7af31a332aeac493571
MD5 7504b858a2a45c1327fb5b5e88db9f95
BLAKE2b-256 1bf8112ff8ffbaceee6b4617e8ffe71b00a1afdcfc4222b1be5fcfc30102d0c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page