mirror of
https://github.com/opencv/opencv.git
synced 2026-10-05 04:03:32 +03:00
python: typing stubs: import typing for Sequence return types
SequenceTypeNode and ClassTypeNode always format as _typing.Sequence[...] and _typing.Type[...], but ContainerTypeNode only reports the typing import as required when compatible_to_runtime_usage is set. Stubs for modules that use these nodes without any other _typing usage (e.g. cv2/videoio_registry) reference _typing without importing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8dcbf62ef3
commit
d3427276fb
1 file changed
+10
@@ -740,6 +740,11 @@ class SequenceTypeNode(ContainerTypeNode):
|
||||
def type_format(self) -> str:
|
||||
return "_typing.Sequence[{}]"
|
||||
|
||||
@property
|
||||
def required_usage_imports(self) -> Generator[str, None, None]:
|
||||
yield "import typing as _typing"
|
||||
yield from super().required_usage_imports
|
||||
|
||||
@property
|
||||
def types_separator(self) -> str:
|
||||
return ", "
|
||||
@@ -896,6 +901,11 @@ class ClassTypeNode(ContainerTypeNode):
|
||||
def type_format(self) -> str:
|
||||
return "_typing.Type[{}]"
|
||||
|
||||
@property
|
||||
def required_usage_imports(self) -> Generator[str, None, None]:
|
||||
yield "import typing as _typing"
|
||||
yield from super().required_usage_imports
|
||||
|
||||
@property
|
||||
def types_separator(self) -> str:
|
||||
return ", "
|
||||
|
||||
Reference in new issue
Block a user