@@ -404,9 +404,9 @@ def get_setter_and_getter_type(member: Member, type_imports: set[str]) -> tuple[
404404 type_ .typename in SPECIAL_NESTED_BASIC_TYPES
405405 ):
406406 if isinstance (member .type , Array ):
407- type_imports .add ('import numpy.typing' )
407+ type_imports .add ('from numpy.typing import NDArray ' )
408408 dtype = SPECIAL_NESTED_BASIC_TYPES [type_ .typename ]['dtype' ]
409- type_annotation = f'numpy.typing. NDArray[{ dtype } ]'
409+ type_annotation = f'NDArray[{ dtype } ]'
410410 elif isinstance (member .type , AbstractSequence ):
411411 type_annotation = f'array.array[{ python_type } ]'
412412
@@ -422,13 +422,11 @@ def get_setter_and_getter_type(member: Member, type_imports: set[str]) -> tuple[
422422 type_annotation = sequence_type
423423
424424 elif isinstance (member .type , AbstractGenericString ) and member .type .has_maximum_size ():
425- type_annotation = 'typing.Union[str, collections.UserString]'
426-
427- type_imports .add ('import collections' )
425+ type_imports .add ('from collections import UserString' )
426+ type_annotation = 'typing.Union[str, UserString]'
428427 elif isinstance (type_ , BasicType ) and type_ .typename == 'char' :
429- type_annotation = 'typing.Union[str, collection.UserString]'
430-
431- type_imports .add ('import collections' )
428+ type_imports .add ('from collections import UserString' )
429+ type_annotation = 'typing.Union[str, UserString]'
432430 elif isinstance (type_ , BasicType ) and type_ .typename == 'octet' :
433431 type_annotation = 'typing.Union[bytes, collections.abc.ByteString]'
434432 else :
0 commit comments