@@ -698,3 +698,46 @@ def f() -> Iterator[int]:
698698 assert annotated .annotation is Iterator [int ]
699699 assert annotated .description == "Integers."
700700 assert not errors
701+
702+
703+ def test_keyword_args_no_type ():
704+ """Parse types for keyword arguments."""
705+
706+ def f (** kwargs ):
707+ """Do nothing.
708+
709+ Keyword arguments:
710+ a: No type.
711+ """
712+
713+ sections , errors = parse (inspect .getdoc (f ), inspect .signature (f ))
714+ assert len (sections ) == 2
715+ kwargs = sections [1 ].value
716+ assert kwargs [0 ].name == "a"
717+ assert kwargs [0 ].annotation is inspect .Parameter .empty
718+ assert kwargs [0 ].description == "No type."
719+ assert kwargs [0 ].kind is inspect .Parameter .KEYWORD_ONLY
720+ assert kwargs [0 ].default is inspect .Parameter .empty
721+ assert len (errors ) == 1
722+ assert "No type annotation for parameter" in errors [0 ]
723+
724+
725+ def test_keyword_args_type ():
726+ """Parse types for keyword arguments."""
727+
728+ def f (** kwargs ):
729+ """Do nothing.
730+
731+ Keyword arguments:
732+ a (int): Typed.
733+ """
734+
735+ sections , errors = parse (inspect .getdoc (f ), inspect .signature (f ))
736+ assert len (sections ) == 2
737+ kwargs = sections [1 ].value
738+ assert kwargs [0 ].name == "a"
739+ assert kwargs [0 ].annotation == "int"
740+ assert kwargs [0 ].description == "Typed."
741+ assert kwargs [0 ].kind is inspect .Parameter .KEYWORD_ONLY
742+ assert kwargs [0 ].default is inspect .Parameter .empty
743+ assert not errors
0 commit comments