File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
sdks/python/apache_beam/transforms Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -1520,9 +1520,8 @@ def _check_fn_use_yield_and_return(fn):
15201520 if lstripped_line .rstrip () == "return None" or lstripped_line .rstrip (
15211521 ) == "return(None)" :
15221522 has_return_none = True
1523- else :
1524- has_return = True
1525- if has_yield and (has_return or has_return_none ):
1523+ has_return = True
1524+ if has_yield and has_return :
15261525 return True
15271526
15281527 if has_return_none :
Original file line number Diff line number Diff line change @@ -115,6 +115,12 @@ def process(self, element):
115115
116116
117117class TestDoFn11 (beam .DoFn ):
118+ """test process returning None (no return and no yield)"""
119+ def process (self , element ):
120+ pass
121+
122+
123+ class TestDoFn12 (beam .DoFn ):
118124 """test process returning None in a filter pattern"""
119125 def process (self , element ):
120126 if element == 0 :
@@ -187,11 +193,16 @@ def test_dofn_with_explicit_return_none(self):
187193 assert RETURN_NONE_PARTIAL_WARNING in self ._caplog .text
188194 assert str (TestDoFn10 ) in self ._caplog .text
189195
190- def test_dofn_with_implicit_return_none_and_value (self ):
196+ def test_dofn_with_implicit_return_none_missing_return_and_yield (self ):
191197 with self ._caplog .at_level (logging .WARNING ):
192198 beam .ParDo (TestDoFn11 ())
193199 assert RETURN_NONE_PARTIAL_WARNING not in self ._caplog .text
194200
201+ def test_dofn_with_implicit_return_none_and_value (self ):
202+ with self ._caplog .at_level (logging .WARNING ):
203+ beam .ParDo (TestDoFn12 ())
204+ assert RETURN_NONE_PARTIAL_WARNING not in self ._caplog .text
205+
195206
196207class PartitionTest (unittest .TestCase ):
197208 def test_partition_with_bools (self ):
You can’t perform that action at this time.
0 commit comments