chadrik commented on a change in pull request #11038: [BEAM-7746] More typing
fixes
URL: https://github.com/apache/beam/pull/11038#discussion_r396700454
##########
File path: sdks/python/apache_beam/coders/coders.py
##########
@@ -387,8 +387,11 @@ def register_structured_urn(urn, cls):
"""Register a coder that's completely defined by its urn and its
component(s), if any, which are passed to construct the instance.
"""
- cls.to_runner_api_parameter = (
- lambda self, unused_context: (urn, None, self._get_component_coders()))
+ setattr(
Review comment:
mypy raises an error when overwriting a method: `Cannot assign to a method`.
using `setattr` avoids the error. A similar situation arises when setting or
getting dynamic attributes.
We need to decide on a policy for these cases:
1) avoid the error using `setattr` and `getattr`
2) silence the error with a `# type: ignore[xxx]` comment
The second option provides more context, but could hinge on how you feel
about the aesthetics of `type ignore` comments.
Either way, I agree a comment should be made on the preceding line to
clarify.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services