This is an automated email from the ASF dual-hosted git repository.
Amar3tto pushed a commit to branch postcommit-python
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/postcommit-python by this push:
new 3faadf0e636 Revert #38797
3faadf0e636 is described below
commit 3faadf0e63683fec48fbbf67b2e1d36b34825e74
Author: Vitaly Terentyev <[email protected]>
AuthorDate: Thu Jun 18 17:59:48 2026 +0400
Revert #38797
---
.../python/apache_beam/options/pipeline_options.py | 9 --------
sdks/python/apache_beam/typehints/opcodes.py | 4 +---
.../apache_beam/typehints/trivial_inference.py | 26 ----------------------
.../typehints/trivial_inference_test.py | 21 +++--------------
sdks/python/apache_beam/typehints/typehints.py | 1 -
sdks/python/setup.py | 5 +----
6 files changed, 5 insertions(+), 61 deletions(-)
diff --git a/sdks/python/apache_beam/options/pipeline_options.py
b/sdks/python/apache_beam/options/pipeline_options.py
index c813939d53f..41f95743897 100644
--- a/sdks/python/apache_beam/options/pipeline_options.py
+++ b/sdks/python/apache_beam/options/pipeline_options.py
@@ -888,15 +888,6 @@ class TypeOptions(PipelineOptions):
default=False,
action='store_true',
help='Disable the use of beartype for type checking.')
- parser.add_argument(
- '--exclude_infer_dataclass_field_type',
- default=False,
- action='store_true',
- help='Exclude certain typehint inference involving dataclass fields '
- 'and resolve to Any (as in beam<=2.74.0). NOTE: this option is '
- 'for backward compatibility only and the exclusion scenarios are '
- 'subject to change or remove in a future version. For details see: '
-
'https://beam.apache.org/releases/pydoc/current/apache_beam.typehints.trivial_inference.html#apache_beam.typehints.trivial_inference.resolve_dataclass_field_type')
# pylint: disable=line-too-long
parser.add_argument(
'--runtime_type_check',
default=False,
diff --git a/sdks/python/apache_beam/typehints/opcodes.py
b/sdks/python/apache_beam/typehints/opcodes.py
index 53eabdadc4a..963b5e0850b 100644
--- a/sdks/python/apache_beam/typehints/opcodes.py
+++ b/sdks/python/apache_beam/typehints/opcodes.py
@@ -42,7 +42,6 @@ from apache_beam.typehints.trivial_inference import
BoundMethod
from apache_beam.typehints.trivial_inference import Const
from apache_beam.typehints.trivial_inference import element_type
from apache_beam.typehints.trivial_inference import key_value_types
-from apache_beam.typehints.trivial_inference import
resolve_dataclass_field_type
from apache_beam.typehints.trivial_inference import union
from apache_beam.typehints.typehints import Any
from apache_beam.typehints.typehints import Dict
@@ -452,9 +451,8 @@ def _getattr(o, name):
elif inspect.isclass(o) and dataclasses.is_dataclass(o):
field = o.__dataclass_fields__.get(name)
if field is not None:
- return resolve_dataclass_field_type(field.type)
+ return field.type
return Any
-
else:
return Any
diff --git a/sdks/python/apache_beam/typehints/trivial_inference.py
b/sdks/python/apache_beam/typehints/trivial_inference.py
index 69edfc30928..68e126a8939 100644
--- a/sdks/python/apache_beam/typehints/trivial_inference.py
+++ b/sdks/python/apache_beam/typehints/trivial_inference.py
@@ -774,29 +774,3 @@ def infer_return_type_func(f, input_types, debug=False,
depth=0):
if debug:
print(f, id(f), input_types, '->', result)
return result
-
-
-def resolve_dataclass_field_type(x):
- """
- Resolve a type to Beam typehint under global pipeline option context.
-
- Since Beam 2.75.0, typehints of dataclass fields are honored during type
- inferences. However, in case of breakage (possible scenarios include
- incorrect typehints; non-deterministic or nullable types disallowed by
- consumer transform but check disabled by Any; tests rely on Any),
- --exclude_infer_dataclass_field_type option to instruct falling back to Any.
- Fields of builtin primitives are always respected.
- """
- from apache_beam.options.pipeline_options_context import get_pipeline_options
- options = get_pipeline_options()
- if options:
- from apache_beam.options.pipeline_options import TypeOptions
- disabled = options.view_as(TypeOptions).exclude_infer_dataclass_field_type
- else:
- disabled = False
-
- if not disabled:
- return typehints.normalize(x)
- if x in (bool, bytes, complex, float, int, str):
- return x
- return Any
diff --git a/sdks/python/apache_beam/typehints/trivial_inference_test.py
b/sdks/python/apache_beam/typehints/trivial_inference_test.py
index dcb0bac97e8..f421819bdca 100644
--- a/sdks/python/apache_beam/typehints/trivial_inference_test.py
+++ b/sdks/python/apache_beam/typehints/trivial_inference_test.py
@@ -24,8 +24,6 @@ import types
import unittest
import apache_beam as beam
-from apache_beam.options.pipeline_options import PipelineOptions
-from apache_beam.options.pipeline_options_context import
scoped_pipeline_options
from apache_beam.typehints import row_type
from apache_beam.typehints import trivial_inference
from apache_beam.typehints import typehints
@@ -491,28 +489,15 @@ class TrivialInferenceTest(unittest.TestCase):
[int])
def testDataClassFields(self):
- @dataclasses.dataclass
- class BaseClass:
- pass
-
@dataclasses.dataclass
class MyDataClass:
id: int
name: str
- tags: list[str]
- custom: BaseClass
self.assertReturnType(
- typehints.Tuple[int, str, typehints.List[str], BaseClass],
- python_callable.PythonCallableWithSource(
- "lambda x: (x.id, x.name, x.tags, x.custom)"), [MyDataClass])
-
- options = PipelineOptions(['--exclude_infer_dataclass_field_type'])
- with scoped_pipeline_options(options):
- self.assertReturnType(
- typehints.Tuple[int, str, typehints.Any, typehints.Any],
- python_callable.PythonCallableWithSource(
- "lambda x: (x.id, x.name, x.tags, x.custom)"), [MyDataClass])
+ typehints.Tuple[int, str],
+ python_callable.PythonCallableWithSource("lambda x: (x.id, x.name)"),
+ [MyDataClass])
if __name__ == '__main__':
diff --git a/sdks/python/apache_beam/typehints/typehints.py
b/sdks/python/apache_beam/typehints/typehints.py
index ffef40de667..6dc88a93dd3 100644
--- a/sdks/python/apache_beam/typehints/typehints.py
+++ b/sdks/python/apache_beam/typehints/typehints.py
@@ -1453,7 +1453,6 @@ _KNOWN_PRIMITIVE_TYPES: typing.Dict[type, typing.Any] = {}
def normalize(x, none_as_type=False):
- """Normalize a type to Beam typehint."""
# None is inconsistantly used for Any, unknown, or NoneType.
# Avoid circular imports
diff --git a/sdks/python/setup.py b/sdks/python/setup.py
index b8fd2f5f834..aabe0395f6d 100644
--- a/sdks/python/setup.py
+++ b/sdks/python/setup.py
@@ -526,10 +526,7 @@ if __name__ == '__main__':
'google-api-core>=2.0.0,<3',
'google-apitools>=0.5.31,<0.5.32; python_version < "3.13"',
'google-apitools>=0.5.35; python_version >= "3.13"',
- # NOTE: Maintainers, please do not require google-auth>=2.x.x
- # Until this issue is closed
- # https://github.com/googleapis/google-cloud-python/issues/10566
- 'google-auth>=1.18.0,<3',
+ 'google-auth>=2.0.0,<3',
'google-auth-httplib2>=0.1.0,<0.3.0',
'google-cloud-datastore>=2.0.0,<3',
'google-cloud-pubsub>=2.1.0,<3',