Skip to content

Commit d0ecd7b

Browse files
committed
stubgen: do not generate 'NoneType'
1 parent 7ce3d0f commit d0ecd7b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/stubgen.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(
128128

129129
# Precompile a regular expression used to extract types from 'types.*'
130130
self.types_re = re.compile(
131-
sep_before + r"(ModuleType|CapsuleType|NoneType|EllipsisType)\b"
131+
sep_before + r"(ModuleType|CapsuleType|EllipsisType)\b"
132132
)
133133

134134
# Precompile a regular expression used to extract nanobind nd-arrays
@@ -137,6 +137,7 @@ def __init__(
137137
)
138138

139139
# Regular expression matching `builtins.*` types
140+
self.none_re = re.compile(sep_before + r"builtins\.(None)Type\b")
140141
self.builtins_re = re.compile(sep_before + r"builtins\.(" + identifier + ")")
141142

142143
# Precompile a regular expression used to extract a few other types
@@ -370,6 +371,7 @@ def replace_standard_types(self, s):
370371
s = self.module_member_re.sub(lambda m: m.group(1), s)
371372

372373
# Remove 'builtins.*'
374+
s = self.none_re.sub(lambda m: m.group(1), s)
373375
s = self.builtins_re.sub(lambda m: m.group(1), s)
374376

375377
# tuple[] is not a valid type annotation

0 commit comments

Comments
 (0)