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

wrap_long_dict_value_in_parens can introduce unnecessary nesting for dicts in dicts #4129

Closed
hauntsaninja opened this issue Dec 28, 2023 · 0 comments · Fixed by #4135
Closed
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. T: bug Something isn't working

Comments

@hauntsaninja
Copy link
Collaborator

Originally reported at #4042 (comment)

Repro:

class Random:
    def func():
        random_service.status.active_states.inactive = (
            make_new_top_level_state_from_dict(
                {
                    "topLevelBase": {
                        "secondaryBase": {
                            "timestamp": 1234,
                            "latitude": 1,
                            "longitude": 2,
                            "actionTimestamp": Timestamp(
                                seconds=1530584000, nanos=0
                            ).ToJsonString(),
                        }
                    },
                }
            )
        )

Enabling just wrap_long_dict_value_in_parens turns this into:

class Random:
    def func():
        random_service.status.active_states.inactive = (
            make_new_top_level_state_from_dict(
                {
                    "topLevelBase": (
                        {
                            "secondaryBase": (
                                {
                                    "timestamp": 1234,
                                    "latitude": 1,
                                    "longitude": 2,
                                    "actionTimestamp": (
                                        Timestamp(
                                            seconds=1530584000, nanos=0
                                        ).ToJsonString()
                                    ),
                                }
                            )
                        }
                    ),
                }
            )
        )
@hauntsaninja hauntsaninja added T: bug Something isn't working C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. labels Dec 28, 2023
hauntsaninja added a commit to hauntsaninja/black that referenced this issue Dec 29, 2023
hauntsaninja added a commit to hauntsaninja/black that referenced this issue Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant