Python stubs #
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 #
PyPi #
It is possible to install stubs directly from PyPI:
pip install FreeCAD-stubs
From GitHub repo (especially older versions) #
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:
-
Clone repo:
git clone https://github.com/ostr00000/freecad-stubs
-
Choose desired version:
git checkout FreeCAD-0-20
-
And install directly:
pip install freecad-stubs
False positives in stubs #
Probably not all types are correctly detected. Reporting issues are very welcome.