Python Practices #
Work in Progress - looking for help!
Naming conventions - PEP8 #
Using well known conventions makes easier for other developers to understand your code and maintain it in the future.
Namespacing #
Use proper namespacing to avoid conflicts with existing packages. It is preferred to put any FreeCAD code in a sub-module of the freecad base namespace.
Tooling #
Code formatting and linting #
-
Ruff: (modern and fast)
-
Black
Main FreeCAD repo uses
blackwith--linelength=100in the pre-commit hook, so if you are submitting code to main, take that into account.
Project management #
The modern tooling for python is uv, it replaces pip and manage dependencies, project metadata, virtual environments, etc… and it is 10x faster than pip.
Typing #
Type hints makes the code safer and more easy to maintain and refactor.
There are many static type checkers:
Python versions #
Current supported python versions in FreeCAD are 3.10+, but some addons may not work with latest python versions.