-
Notifications
You must be signed in to change notification settings - Fork 624
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
Describe isort's multi_line_output setting #109
Describe isort's multi_line_output setting #109
Conversation
Related: #36, #95 (comment). |
5f20641
to
5154805
Compare
@@ -64,8 +64,7 @@ | |||
from contextlib import contextmanager | |||
import typing | |||
|
|||
from opentelemetry import loader | |||
from opentelemetry import types | |||
from opentelemetry import loader, types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't import multiple modules in a single line (other names are fine, but modules should be one per line).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we could lint this, but I presume not an easy to figure out what's a module and and object here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@toumorokoshi Since you approved the PR but made this comment, I'm not sure what's your opinion on such imports? Do you prefer importing multiple submodules on the same line or each on their own line.
Ad linters: I think pylint knows quite a bit about the meaning of these names. There is no check against it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion isn't strong enough for me to argue the point, but I actually prefer multiple per line. My personal favorite way to refer to an import is Rust syntax, which enables a lot of flexibility with a visually intuitive ident-as-namespace:
https://doc.rust-lang.org/reference/items/use-declarations.html
I think for those who don't use an ide, importing modules exclusively is really helpful. It makes it easy to see what belongs to a module vs what is a local reference:
foo = Foo()
other_object = other_module.Bar()
Once I know it's referenced locally or imported, I then make the determination to go to the top of the file, or to search for the next reference. But I use the go-to-definition functionality of my ide, and so the organization doesn't affect me either away.
The only thing I really dislike is star imports. But I think most people agree on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Oberon00 it looks like the only way to use isort
consistently with black
is to allow grouped imports for module names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I realize this is just a question of stylistic preferences...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I would suggest adding something in the squashed commit to reference the discussion around the isort changes, or file that in a separate issue. Somewhere where the discussion can be easily referenced.
Would it be a good idea to add |
@mauriciovasquezbernal That sounds very useful but should be a separate PR. |
These changes follow up the "Fix and improve tests for Python != 3.7" PR. The multi_line_output was already set to 3 in the "Add initial black formatting" PR, so after rebasing to master this commit contains only comment that describes a magic number from the isort configuration file. Corresponding PR: - open-telemetry#109 Related discussions: - open-telemetry#95 (comment) - open-telemetry#95 (comment)
5154805
to
eaf0118
Compare
Hi there, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me as a description of the current config.
These changes follow up the "Fix and improve tests for Python != 3.7" PR. The multi_line_output was already set to 3 in the "Add initial black formatting" PR, so after rebasing to master this commit contains only comment that describes a magic number from the isort configuration file. Corresponding PR: - open-telemetry/opentelemetry-python#109 Related discussions: - open-telemetry/opentelemetry-python#95 (comment) - open-telemetry/opentelemetry-python#95 (comment)
Hello,
These changes follow up #95.
The
multi_line_output
was already set to3
in the Add initial black formatting PR, so after rebasing tomaster
this commit contains only comment that describes a magic number from theisort
configuration file.Related discussions: