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
4 changes: 4 additions & 0 deletions sdks/python/apache_beam/typehints/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def foo((a, b)):

_ANY_VAR_POSITIONAL = typehints.Tuple[typehints.Any, ...]
_ANY_VAR_KEYWORD = typehints.Dict[typehints.Any, typehints.Any]
# TODO(BEAM-8280): Remove this when from_callable is ready to be enabled.
_enable_from_callable = False

try:
_original_getfullargspec = inspect.getfullargspec
Expand Down Expand Up @@ -229,6 +231,8 @@ def from_callable(fn):
Returns:
A new IOTypeHints or None if no annotations found.
"""
if not _enable_from_callable:
return None
signature = get_signature(fn)
if (all(param.annotation == param.empty
for param in signature.parameters.values())
Expand Down
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/typehints/decorators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from apache_beam.typehints import WithTypeHints
from apache_beam.typehints import decorators

decorators._enable_from_callable = True


class IOTypeHintsTest(unittest.TestCase):

Expand Down
1 change: 1 addition & 0 deletions sdks/python/apache_beam/typehints/decorators_test_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from apache_beam.typehints import TypeVariable
from apache_beam.typehints import decorators

decorators._enable_from_callable = True
T = TypeVariable('T')


Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/typehints/typed_pipeline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
from apache_beam.testing.util import assert_that
from apache_beam.testing.util import equal_to
from apache_beam.typehints import WithTypeHints
from apache_beam.typehints import decorators
from apache_beam.typehints.decorators import get_signature

# These test often construct a pipeline as value | PTransform to test side
# effects (e.g. errors).
# pylint: disable=expression-not-assigned

decorators._enable_from_callable = True


class MainInputTest(unittest.TestCase):

Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/typehints/typed_pipeline_test_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

import apache_beam as beam
from apache_beam import typehints
from apache_beam.typehints import decorators

decorators._enable_from_callable = True


class MainInputTest(unittest.TestCase):
Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/typehints/typehints_test_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
from apache_beam.transforms.core import DoFn
from apache_beam.typehints import KV
from apache_beam.typehints import Iterable
from apache_beam.typehints import decorators

decorators._enable_from_callable = True


class TestParDoAnnotations(unittest.TestCase):
Expand Down