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

__main__ is considered third party by isort #8750

Closed
Numerlor opened this issue Nov 18, 2023 · 3 comments · Fixed by #8805
Closed

__main__ is considered third party by isort #8750

Numerlor opened this issue Nov 18, 2023 · 3 comments · Fixed by #8805
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Numerlor
Copy link

import os

import __main__
import third_party

import first_party

os.a
third_party.a
__main__.a
first_party.a

formatting the four imports results in the above order instead of

import os

import third_party

import __main__
import first_party

https://play.ruff.rs/e1e21a3a-5567-4c46-9f6d-5ef508551206

@charliermarsh charliermarsh added the bug Something isn't working label Nov 18, 2023
@charliermarsh
Copy link
Member

It seems that isort does the same, but I guess that's also a bug?

@zanieb zanieb added the good first issue Good for newcomers label Nov 20, 2023
@Ezrashaw
Copy link
Contributor

I'd like to work on this. I assume that __main__ just has to be special-cased?

@charliermarsh
Copy link
Member

That's right -- mostly likely in here:

pub(crate) fn categorize<'a>(

charliermarsh pushed a commit that referenced this issue Nov 21, 2023
## Summary

Fixes #8750. `import __main__` is now considered a first-party import,
and is grouped accordingly by the linter and formatter.

## Test Plan

Added a test based off code supplied in the linked issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants