Skip to content
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

Catch mutable default argument #1685

Closed
wants to merge 1 commit into from
Closed

Conversation

eapolinario
Copy link
Collaborator

@eapolinario eapolinario commented May 23, 2024

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
@eapolinario
Copy link
Collaborator Author

@eapolinario
Copy link
Collaborator Author

As expected, the lint job failed with:

examples/advanced_composition/advanced_composition/map_task.py:13:36: B006 Do not use mutable data structures for argument defaults
examples/advanced_composition/advanced_composition/map_task.py:56:54: B006 Do not use mutable data structures for argument defaults
examples/advanced_composition/advanced_composition/map_task.py:69:63: B006 Do not use mutable data structures for argument defaults
examples/advanced_composition/advanced_composition/map_task.py:79:25: B006 Do not use mutable data structures for argument defaults
examples/advanced_composition/advanced_composition/map_task.py:79:64: B006 Do not use mutable data structures for argument defaults
examples/advanced_composition/advanced_composition/subworkflow.py:33:53: B006 Do not use mutable data structures for argument defaults
examples/advanced_composition/advanced_composition/subworkflow.py:33:80: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/documenting_workflows.py:11:40: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/documenting_workflows.py:11:67: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/documenting_workflows.py:29:39: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/documenting_workflows.py:29:66: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/documenting_workflows.py:55:40: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/documenting_workflows.py:55:67: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/named_outputs.py:36:49: B006 Do not use mutable data structures for argument defaults
examples/basics/basics/named_outputs.py:36:76: B006 Do not use mutable data structures for argument defaults
examples/data_types_and_io/data_types_and_io/pickle_type.py:54:[24](https://github.com/flyteorg/flytesnacks/actions/runs/9212079968/job/25342931456?pr=1685#step:7:25): B006 Do not use mutable data structures for argument defaults
examples/data_types_and_io/data_types_and_io/pickle_type.py:55:25: B006 Do not use mutable data structures for argument defaults
examples/pandera_plugin/pandera_plugin/basic_schema_example.py:120:18: B006 Do not use mutable data structures for argument defaults
examples/pandera_plugin/pandera_plugin/basic_schema_example.py:124:36: B006 Do not use mutable data structures for argument defaults
Found 19 errors.
No fixes available (19 hidden fixes can be enabled with the `--unsafe-fixes` option).

@eapolinario
Copy link
Collaborator Author

Looking into this again, I'm not certain we should enable this in flytesnacks examples by default. I know it propagates an anti-pattern, but at the same time, at least for workflows (and soon tasks too) it's pretty handy to have things like default lists and for the simple case we can't misuse the feature (since the lists won't be modified between task executions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] Prevent using mutable default arguments in flytesnacks
3 participants