-
Notifications
You must be signed in to change notification settings - Fork 22
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
Document first_party and relative being the same section vs isort #30
Comments
Since this issue is about documenting the behavior I'm guessing it is intentional? I grew fond of the split between first party and local. Local imports are usually used for functionality that is not publicly exposed or at least not in the same location. Having a split between these two sections makes clear. |
Yes, it's intentional, mainly for simplicity. The real-world examples I've seen of mixing absolute first-party and relative imports have all seemed pretty strange to mix (relative gets you shorter and easier to vendor, while absolute is more explicit). Do you have an example of mixed imports that's not from people copy-pasting? I don't know if this is helpful for torchvision but you can configure the categories on the open-source version to keep your absolute imports separate: [tool.usort]
categories = ["future", "standard_library", "third_party", "my_torchvision", "first_party"]
first_party_detection = false
[tool.usort.known]
my_torchvision = ["torchvision"] |
Simplicity of implementation or something else? I imagine detecting relative imports should be quite easy since they always start with a dot.
I can only give you a toy one: I usually draw the line between absolute and relative imports for public and private functionalities. Given a setup like
the content of from foo.bar import spam
from ._bar import ham If someone inspects the code, they can see at a glance that
So does that mean that now only relative imports get sorted into the |
Yes, that's what I see your toy example, and while I'm generally against boolean flags if you want to send a PR I can review. |
I'm kinda packed right now, so I'll live with the workaround for now. |
Now that we normalize whitespace between sections, this means that we remove a blank line that already-sorted code likely has.
The text was updated successfully, but these errors were encountered: