pep585-upgrade
pep585-upgrade copied to clipboard
Shebang is not respected
Input:
#!/usr/bin/env python3
from typing import AbstractSet
s: AbstractSet
Output:
from collections.abc import Set
#!/usr/bin/env python3
s: Set
I didn't prepare the fix yet, but I think that the best solution would be to save the first occurrence of non-comment, non-docstring expressions while scanning AST and put the imports before that. What do you think?
I see that I never responded here, sorry about @rominf. Would you still like to fix this? No pressure 🙂
If you do, I think your suggestion sounds good 👍
Sorry, I'm not interested (at least for now), because of the old version of MyPy in repos, which doesn't support pep585.
@rominf Hack: If you're using isort in the pre-commit, add pep5-updgrade before isort. The upgrade script will add import at the top and isort will properly order the imports. Also the PR idea can be leveraged to check for shebang line.
I'm officially deprecating this project, as pyupgrade now fills the gap this once did. The package can still be used, but I'm not intending to spend any more time maintaining it, so closing this for now 🙂