Python stubs

Python stubs.

a cover alternative title

Python stubs Link to this heading

Python is a dynamically typed language, so there is no error when compiling (Yes, Python can compile. Compiling/interpreting is an abstract concept, language independent. See more on stackoverflow ). Instead, an error is reported at runtime which may significantly slow down developing process.

To overcome this problem, Python introduced Type Hints . Using an external tool (type checker like Mypy , Pyright ) it is possible to detect runtime errors.

Also, stub files allow IDE (integrated development environment) detect possible names for imported classes or method names.

Installation Link to this heading

PyPi Link to this heading

It is possible to install stubs directly from PyPI :

pip install FreeCAD-stubs

From GitHub repo (especially older versions) Link to this heading

To install stubs for older FreeCAD version (replace FreeCAD-0-20 with tag/branch you want), you can run:

pip install git+https://github.com/ostr00000/freecad-stubs.git@FreeCAD-0-20

Or manually using cloning repo:

  1. Clone repo :

    git clone https://github.com/ostr00000/freecad-stubs
    
  2. Choose desired version:

    git checkout FreeCAD-0-20
    
  3. And install directly:

    pip install freecad-stubs
    

False positives in stubs Link to this heading

Probably not all types are correctly detected. Reporting issues are very welcome.