Skip to content

STYLE Reduce merge conflicts with force_single_line or force_grid_wrap=1 #50274

Closed
@MarcoGorelli

Description

@MarcoGorelli

About 2 years ago, we introduced force_grid_wrap to reduce merge conflicts due to imports #39780

This helped, but we do better in the case when there's a single import per group.

For example, in #49736 the diff was:

- from typing import Iterator
+ from typing import (
+     Generic,
+     Iterator,
+     TypeVar,
+ )

, which caused conflicts when backporting to 1.5.x, because 1.5.x didn't have the Iterator import

If the import style had instead been:

from typing import Generic
from typing import Iterator
from typing import TypeVar

then the PR above could have just added the Generic and TypeVar imports, without touching the Iterator import, and the backport wouldn't have had this conflict

As an aside, this would also remove nearly 5,000 lines of code


This is how it would look like: #50275


An alternative would be to have forced

from typing import (
    Iterator,
)

, see #51693

This makes imports a lot longer, but has the same effect of reducing conflicts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code StyleCode style, linting, code_checks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions