File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -149,6 +149,28 @@ def foo(a: int | None=..., b: int=...) -> None: ...
149149 result = transformer .python_to_stub (source )
150150 assert expected == result
151151
152+ def test_optional_without_default (self ):
153+ source = dedent (
154+ '''
155+ def foo(a):
156+ """
157+ Parameters
158+ ----------
159+ a : int, optional
160+ """
161+ '''
162+ )
163+ expected = dedent (
164+ """
165+ def foo(a: int) -> None: ...
166+ """
167+ )
168+
169+ transformer = Py2StubTransformer ()
170+ # TODO should warn about a required arg being marked "optional"
171+ result = transformer .python_to_stub (source )
172+ assert expected == result
173+
152174 # fmt: off
153175 @pytest .mark .parametrize (
154176 ("assign" , "expected" ),
@@ -376,7 +398,7 @@ class Foo:
376398 b: str = ""
377399 # docstub: on
378400 c: int = None
379- b : str = ""
401+ d : str = ""
380402 """
381403 )
382404 expected = dedent (
@@ -387,7 +409,7 @@ class Foo:
387409 b: str = ""
388410
389411 c: int
390- b : str
412+ d : str
391413 """
392414 )
393415 transformer = Py2StubTransformer ()
You can’t perform that action at this time.
0 commit comments