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

Incorrect third vs first party categorization - namespace packages #1443

Closed
gaborbernat opened this issue Sep 1, 2020 · 9 comments · Fixed by #1537, hypothesis/viahtml#107 or wwade/jobrunner#63
Labels
bug Something isn't working
Milestone

Comments

@gaborbernat
Copy link

https://github.com/PyCQA/isort/blob/develop/isort/place.py#L65-L71 only considers the root module name when trying to categorize a package as first party. This causes issues when your project only contains a part of that module (e.g. in case of namespace packages). Setting known_first_party to root.a will mean that root.b will also be categorized as first party even though it's third party:

root
├── __init__.py
├── a
│   └── __init__.py
└── b
    └── __init__.py
@timothycrosley timothycrosley added the bug Something isn't working label Sep 1, 2020
@timothycrosley
Copy link
Member

Thanks for reporting this issue! This is an embarrassing omission on my part. I had hoped to get a fix for this out in for 5.5.0, but I don't want to rush the change while pushing out some changes needed for improved VSCode integration. Expect to see this fixed in the next minor release (5.6.0)

Thanks!

~Timothy

@timothycrosley timothycrosley added this to the 5.6.0 milestone Sep 3, 2020
@ofek
Copy link
Contributor

ofek commented Sep 8, 2020

I think this is happening to us too #1467

@gaborbernat
Copy link
Author

@timothycrosley any ETA on this?

@timothycrosley
Copy link
Member

@gaborbernat the next minor release is scheduled for October 1st, I'll try to make sure the change is in develop soon so that you and others can test the new functionality before it's released to PyPI

@timothycrosley
Copy link
Member

This is fixed in develop and, void of issues being discovered before then, will be deployed with the 5.6.0 release of isort tonight.

The solution as coded exposes two new configuration options to tweak the behaviour if needed:

  • auto_identify_namespace_packages (defaults to True): enables toggling the new automatic namespace package identification.
  • namespace_packages: Enables manually specifying a list of namespace packages.

Thanks!

~Timothy

@gaborbernat
Copy link
Author

Was this released part of 5.5.5 and just msised from the changelog? 🤔

@timothycrosley
Copy link
Member

@gaborbernat nope! There will be another release tonight, but since it is rather large for a minor release I wanted to make sure that the one major issue in the 5.5.x series was released separately in case any of the changes in 5.6.0 are harder to accommodate by any individual projects

@timothycrosley
Copy link
Member

This is now live with release 5.6.0 of isort https://pycqa.github.io/isort/CHANGELOG/#560-october-7-2020.

I apologize for the extended timeline for the release, but hope there are enough good things in it to make up for it!

@gaborbernat
Copy link
Author

No worries, much appreciated now it's released

clap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment