ruff
7571da87 - Preserve trailing inline comments on import-from statements (#12498)

Commit
1 year ago
Preserve trailing inline comments on import-from statements (#12498) ## Summary Right now, in the isort comment model, there's nowhere for trailing comments on the _statement_ to go, as in: ```python from mylib import ( MyClient, MyMgmtClient, ) # some comment ``` If the comment is on the _alias_, we do preserve it, because we attach it to the alias, as in: ```python from mylib import ( MyClient, MyMgmtClient, # some comment ) ``` Similarly, if the comment is trailing on an import statement (non-`from`), we again attach it to the alias, because it can't be parenthesized, as in: ```python import foo # some comment ``` This PR adds logic to track and preserve those trailing comments. We also no longer drop several other comments, like: ```python from mylib import ( # some comment MyClient ) ``` Closes https://github.com/astral-sh/ruff/issues/12487.
Author
Parents
Loading