Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

don't add another import line from same package #29

Closed
kretes opened this issue May 5, 2022 · 1 comment
Closed

don't add another import line from same package #29

kretes opened this issue May 5, 2022 · 1 comment

Comments

@kretes
Copy link

kretes commented May 5, 2022

For an input file like this:

from collections.abc import Callable

from typing import Collection

def a(a: Callable, b: Collection):
    pass

when applying pep585 hook I get:

from collections.abc import Collection
from collections.abc import Callable

def a(a: Callable, b: Collection):
    pass

while I expect:

from collections.abc import Callable, Collection

def a(a: Callable, b: Collection):
    pass

It could be argued this is the job of e.g. isort, however - pep585-upgrade already tries to be nice in terms of imports - e.g. in a larger import set - this new import line gets added nearby other import from same package and not at the end (which would be simplest I guess)

@sondrelg
Copy link
Member

sondrelg commented May 5, 2022

PRs are welcome, but I would indeed argue that this is out of scope for the package. Better to pair it with isort and call it a day in my opinion.

Pyupgrade also supports upgrading some of these type hints now (didn't when I wrote this), so I'd consider this package more useful as sort of a codemod for entire projects, to do one-time upgrades.

@sondrelg sondrelg closed this as completed Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants