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

Imports treated as wrong type #1181

Closed
ZryletTC opened this issue Apr 24, 2020 · 4 comments
Closed

Imports treated as wrong type #1181

ZryletTC opened this issue Apr 24, 2020 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@ZryletTC
Copy link

Some modules my organization uses have classes with all-uppercase names for devices with acronym names. Unfortunately, this causes them to look like constants in the eyes of PEP8 and therefore isort rules. For example: (both BeckhoffAxis and IMS are classes)

Expected sort:

from .epics_motor import BeckhoffAxis, IMS

Current sort:

from .epics_motor import IMS, BeckhoffAxis

I ran a few other tests, and as far as I can tell, isort is reading IMS as a constant and therefore moving it to the front of the list. I saw that this can be turned off using the order_by_type setting but we want this left on so that other types that we import are sorted separately.

Would it be possible to either:

  • Support known_type settings like known_class similar to how the known_{section} settings are used?
  • Have the type detected from the source file instead of by the name? (I understand why this option is tricky and can lead to other issues, but maybe just as an option when dealing with local imports?)
@timothycrosley timothycrosley added the enhancement New feature or request label Jul 4, 2020
@timothycrosley
Copy link
Member

The second option is unlikely to ever be supported because of how much magic that would require. However, I think the first is a great idea and would happily accept a pull request that supported it.

Thanks!

~Timothy

@johnthagen
Copy link

Related to #1259, I think at least updating the docs to state that it's not actually ordering by type, but really it's using case-sensitivity, would help explain what's going on.

@timothycrosley timothycrosley added this to the 5.3.0 milestone Aug 5, 2020
@timothycrosley
Copy link
Member

This is implemented in develop and will be released in version 5.3.0 via the following new options:

constants=,classes=,variables=

Thanks!

~Timothy

@timothycrosley
Copy link
Member

5.3.0 has now been released to PyPI

Thanks!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants