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

Breaking change: Don't extract value from 1-length dict #399

Merged

Conversation

mski-iksm
Copy link
Contributor

@mski-iksm mski-iksm commented Sep 28, 2024

FIX: #293

As mentioned in above issue, when loading 1-length dictionary with self.load() (no target specified), the value of dict will be loaded instead of dictionary itself.

Although this feature allows shorthand as described in the issue, the benefit is very limited and disadvantage caused by confusion is more significant.

Therefore, I want to delete this implementation.


This PR will cause following change.

class A(gokart.TaskOnKart):
    task_a = gokart.TaskInstanceParameter()

    def run(self):
        a = self.load()
        # From this PR, `a` will become a dictionary, instead of value of output of task_a
        # so, if you want to extract the value, you must specify key name as
        # a = self.load('task_a')

@mski-iksm mski-iksm changed the title Don't extract value from 1-length dict Breaking change: Don't extract value from 1-length dict Sep 28, 2024
Copy link
Collaborator

@hirosassa hirosassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nits comment

gokart/task.py Outdated Show resolved Hide resolved
Copy link
Contributor

@hiro-o918 hiro-o918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@hirosassa hirosassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kitagry kitagry merged commit 8bd8fe0 into m3dev:master Sep 29, 2024
5 checks passed
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.

Dict with length 1 loses its key after self.load()
4 participants