You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/hacking-guide.rst
+22
Original file line number
Diff line number
Diff line change
@@ -65,4 +65,26 @@ Coding conventions
65
65
**pyelftools** is written in Python, following the `PEP 8 <http://www.python.org/dev/peps/pep-0008/>`_ style guide.
66
66
67
67
68
+
Type checking
69
+
-------------
68
70
71
+
**pyelftools** is using and providing Type Hints, following the `PEP 484 <https://peps.python.org/pep-0484/>`_.
72
+
Please make sure new functions and methods are properly type hinted.
73
+
There are some known limitations as **pyelftools** is dynamic for some types, which does not work well for _static typing_.
74
+
75
+
Please make sure to run [pyright](https://github.com/microsoft/pyright) and/or [mypy](https://mypy.readthedocs.io/en/stable/) on your contributions.
76
+
For this Python 3.12 (or newer) is required:
77
+
78
+
.. sourcecode:: text
79
+
80
+
> uv sync --dev --group typing --python 3.12
81
+
> . .venv/bin/activate
82
+
> pyright
83
+
> mypy
84
+
85
+
You can also install ``pyright`` or ``mypy`` globally and (re-)use them for multiple projects:
86
+
87
+
1. either install them once with ``uv tool install -p 3.12 pyright`` respective ``uv tool install -p 3.12 mypy``. Afterwards you can directly invoke ``pyright`` or ``mypy``.
88
+
2. or run them from a temporary VENV each time by using ``uv tool run -p 3.12 pyright`` respective ``uv tool run -p 3.12 mypy``.
89
+
90
+
Compared to the recommendation above this has the drawback that (in the future) type hints for external dependencies might be missing.
0 commit comments