Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions sdks/python/apache_beam/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,12 @@ def apply(
'streaming jobs.' % full_label)
self.applied_labels.add(full_label)

if pvalueish is None:
full_label = self._current_transform().full_label
raise TypeCheckError(
f'Transform "{full_label}" was applied to the output of '
f'an object of type None.')

Comment on lines +769 to +774
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bummer to lose the name of the transform that produced the "None", but doesn't look like there's an easy way to capture that.

pvalueish, inputs = transform._extract_input_pvalues(pvalueish)
try:
if not isinstance(inputs, dict):
Expand Down Expand Up @@ -805,9 +811,6 @@ def apply(
self._assert_not_applying_PDone(pvalueish, transform)

pvalueish_result = self.runner.apply(transform, pvalueish, self._options)
if pvalueish_result is None:
pvalueish_result = pvalue.PDone(self)
pvalueish_result.producer = current

if type_options is not None and type_options.pipeline_type_check:
transform.type_check_outputs(pvalueish_result)
Expand Down
4 changes: 1 addition & 3 deletions sdks/python/apache_beam/pipeline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ class ParentTransform(PTransform):
def expand(self, pcoll):
return pcoll | DoNothingTransform()

with pytest.raises(
TypeCheckError,
match=r".*applied to the output.*ParentTransform/DoNothingTransform"):
with pytest.raises(TypeCheckError, match=r".*applied to the output"):
with TestPipeline() as pipeline:
_ = pipeline | ParentTransform() | beam.Map(lambda x: x + 1)

Expand Down
Loading