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: README.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,18 @@ Those stub files can later be used in PyCharm to enhance the development experie
6
6
7
7
You can either use the stubs released [here][latest-release], or follow the instructions below to generate them yourself.
8
8
9
-
To use the stubs in PyCharm, follow the instructions in [Install, uninstall, and upgrade interpreter paths][interpreter-paths].
10
9
11
-
### Using The Stubs
10
+
## Using The Stubs
11
+
12
+
### Installation
13
+
14
+
The release contains [PEP 0561 stub package][pep-0561], which can simply be installed with `pip install ghidra-stubs*.whl`
15
+
into the environment in which the real `ghidra` module is available. Any conformant tool will then use the stub package
16
+
for type analysis purposes.
17
+
18
+
If you want to manually add the stub files to PyCharm, follow the instructions in [Install, uninstall, and upgrade interpreter paths][interpreter-paths].
19
+
20
+
### Usage
12
21
13
22
Once installed, all you need to do is import the Ghidra modules as usual, and PyCharm will do the rest.
14
23
@@ -22,11 +31,27 @@ But the `.pyi` gives PyCharm all the information it needs to help you.
22
31
23
32
```python
24
33
try:
25
-
from ghidra_builtins import*
34
+
fromghidra.ghidra_builtins import*
26
35
except:
27
36
pass
28
37
```
29
38
39
+
If you are using [ghidra_bridge](https://github.com/justfoxing/ghidra_bridge) from a Python 3 environment where no real `ghidra` module
40
+
exists you can use a snippet like the following:
41
+
42
+
```python
43
+
import typing
44
+
if typing.TYPE_CHECKING:
45
+
import ghidra
46
+
from ghidra.ghidra_builtins import*
47
+
else:
48
+
b = ghidra_bridge.GhidraBridge(namespace=globals())
49
+
50
+
# actual code follows here
51
+
```
52
+
53
+
`typing.TYPE_CHECKING` is a special value that is always `False` at runtime but `True` during any kind of type checking or completion.
0 commit comments