Skip to content

wrap_long_dict_value_in_parens can introduce unnecessary nesting for dicts in dicts #4129

@hauntsaninja

Description

@hauntsaninja

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()
                                    ),
                                }
                            )
                        }
                    ),
                }
            )
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions