Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiline import statements (proposal for issue #8) #63

Merged
merged 13 commits into from Aug 23, 2020

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Mar 2, 2020

Hi @myint. Thank you very much for creating this awesome project.

This PR is my proposal on how to close #8. I hope you find it relevant.

It still skips difficult scenarios like lines joined by a semicolon, inline try-catch, comments and etc, but I think tackling everything would increase the complexity of the code to an undesired level.

Such as:
- leading/trailing commas/line continuation
- try/except
- semicolon
- empty imports as result

In some cases the approach of "not changing anything if it is too risk"
was adopted (as already happens in other parts of the code).
Unfortunately treating inline comments inside imports increases the
complexity in the implementation.
This change reduces complexity by refusing to change multiline import
statements that contain comments.

This approach is also used in other parts of the code.
... By using the existing code as a template.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 99.335% when pulling d86860d on abravalheri:fix-multiline-from-imports into 095161e on myint:master.

@coveralls
Copy link

coveralls commented Mar 2, 2020

Coverage Status

Coverage increased (+0.02%) to 99.345% when pulling 06431f6 on abravalheri:fix-multiline-from-imports into 095161e on myint:master.

@myint
Copy link
Member

myint commented May 17, 2020

Thanks! I'll have to review this in more detail when I get a chance.

@kkoomen
Copy link

kkoomen commented May 23, 2020

@myint Please review this MR and merge whenever possible. This should be fixed.

Copy link
Member

@myint myint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@myint myint merged commit e14b5c3 into PyCQA:master Aug 23, 2020
@abravalheri abravalheri deleted the fix-multiline-from-imports branch March 10, 2022 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle multiline import-from statements
4 participants