-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Ruff B008 errors #6952
Fix Ruff B008 errors #6952
Conversation
@@ -140,8 +140,10 @@ def verify_beam_pipeline_arg(a: int) -> OutputDict(b=float): # pytype: disable= | |||
|
|||
def verify_beam_pipeline_arg_non_none_default_value( | |||
a: int, | |||
beam_pipeline: BeamComponentParameter[beam.Pipeline] = beam.Pipeline(), | |||
beam_pipeline: BeamComponentParameter[beam.Pipeline] = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beam_pipeline: BeamComponentParameter[beam.Pipeline] = None
looks better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the test case is to verify the default value to not none, the test case fails with below error:
FAILED tfx/dsl/component/experimental/decorators_test.py::ComponentDecoratorTest::testBeamPipelineDefaultIsNotNoneFails - TypeError: Argument a should be a Channel of type <class 'tfx.types.standard_artifacts.Integer'> (got 1)
Hence I have assigned default value as 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. The typing error is pretty clear. You cannot assign an integer to other type.
If it is to avoid B008, then how's about doing it in this way?
_TestBeamPipelineArgs = ['--my_testing_beam_pipeline_args=foo']
_TestEmptyBeamPipeline = beam.Pipeline() # <- Newly added
...
def verify_beam_pipeline_arg_non_none_default_value(
a: int,
beam_pipeline: BeamComponentParameter[beam.Pipeline] = _TestEmptyBeamPipeline,
) -> OutputDict(b=float): # pytype: disable=invalid-annotation,wrong-arg-types
del beam_pipeline
return {'b': float(a)}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That works. I have updated.
@@ -140,8 +140,10 @@ def verify_beam_pipeline_arg(a: int) -> TypedDict('Output6', dict(b=float)): # | |||
|
|||
def verify_beam_pipeline_arg_non_none_default_value( | |||
a: int, | |||
beam_pipeline: BeamComponentParameter[beam.Pipeline] = beam.Pipeline(), | |||
beam_pipeline: BeamComponentParameter[beam.Pipeline] = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error:
FAILED tfx/dsl/component/experimental/decorators_typeddict_test.py::ComponentDecoratorTest::testBeamPipelineDefaultIsNotNoneFails - TypeError: Argument a should be a Channel of type <class 'tfx.types.standard_artifacts.Integer'> (got 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just added some minor comments
#6945