Skip to content

Commit 4c0534a

Browse files
committed
Add __all__ to all modules to make star imports work better
1 parent fbb5d5c commit 4c0534a

9 files changed

+53
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Internal changes
99

1010
- Update and freeze dependencies for documentation generation
1111
- Refactored the code to parse MI records to decrease the number of regex matches to perform
12+
- Added `__all__` to all modules, which means that star imports (like `from pygdbmi.gdbmiparser import *`) will not pollute the namespace with modules used by pygdbmi itself
1213

1314
## 0.10.0.2
1415

pygdbmi/IoManager.py

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
else:
2525
import fcntl
2626

27+
28+
__all__ = [
29+
"IoManager",
30+
"make_non_blocking",
31+
]
32+
33+
2734
logger = logging.getLogger(__name__)
2835

2936

pygdbmi/StringStream.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from pygdbmi.gdbescapes import advance_past_string_with_gdb_escapes
22

33

4+
__all__ = ["StringStream"]
5+
6+
47
class StringStream:
58
"""A simple class to hold text so that when passed
69
between functions, the object is passed by reference

pygdbmi/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
__version__ = "0.10.0.2"
2+
3+
__all__ = [
4+
"IoManager",
5+
"gdbcontroller",
6+
"gdbmiparser",
7+
]

pygdbmi/constants.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import os
22

3+
4+
__all__ = [
5+
"DEFAULT_GDB_TIMEOUT_SEC",
6+
"DEFAULT_TIME_TO_CHECK_FOR_ADDITIONAL_OUTPUT_SEC",
7+
"GdbTimeoutError",
8+
"USING_WINDOWS",
9+
]
10+
11+
312
DEFAULT_GDB_TIMEOUT_SEC = 1
413
DEFAULT_TIME_TO_CHECK_FOR_ADDITIONAL_OUTPUT_SEC = 0.2
514
USING_WINDOWS = os.name == "nt"

pygdbmi/gdbcontroller.py

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
DEFAULT_TIME_TO_CHECK_FOR_ADDITIONAL_OUTPUT_SEC,
1414
)
1515

16+
17+
__all__ = ["GdbController"]
18+
19+
1620
DEFAULT_GDB_LAUNCH_COMMAND = ["gdb", "--nx", "--quiet", "--interpreter=mi3"]
1721
logger = logging.getLogger(__name__)
1822

pygdbmi/gdbescapes.py

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
from typing import Iterator, Tuple
77

88

9+
__all__ = [
10+
"advance_past_string_with_gdb_escapes",
11+
"unescape",
12+
]
13+
14+
915
def unescape(escaped_str: str) -> str:
1016
"""Unescape a string escaped by GDB in MI mode.
1117

pygdbmi/gdbmiparser.py

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
from pygdbmi.StringStream import StringStream
1717
from pygdbmi.gdbescapes import unescape
1818

19+
20+
__all__ = [
21+
"parse_response",
22+
"response_is_finished",
23+
]
24+
25+
1926
_DEBUG = False
2027
logger = logging.getLogger(__name__)
2128

pygdbmi/printcolor.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import os
22

3+
4+
__all__ = [
5+
"fmt_cyan",
6+
"fmt_green",
7+
"print_cyan",
8+
"print_green",
9+
"print_red",
10+
]
11+
12+
313
USING_WINDOWS = os.name == "nt"
414

515

0 commit comments

Comments
 (0)