Closed LKI closed 6 years ago
Could you link to something that states PyCharm uses this style?
There is nothing that specifically states that the import order is case sensitive in the docs, but I can confirm with empirical usage that it does sort capital letters before lowercase. References for available options below:
https://www.jetbrains.com/help/pycharm/code-style-python.html
Select or clear this checkbox to enable or disable sorting imports within individual import groups according to PEP 8.
If this checkbox is selected, the imports in the from ... import ...
statements are sorted alphabetically
# Selected
from sys import modules, path, version
# Not selected
from sys import version, path, modules
If this checkbox is not selected, the imports from the same module, regardless of their type, are grouped together, but so that import statements go first, and from ... import ...
statements go next.
If this checkbox is selected, the imports are at first sorted by there type (first import, next from ... import ...
), and then alphabetically.
# Selected
import os
import sys
from os import getenv
from sys import path
# Not selected
import os
from os import getenv
import sys
from sys import path
The option Sort plain and 'from' imports separately within a group corresponds to the option force_alphabetical_sort of the utility isort.
Also, this sorting order corresponds to Google Python Style Guide
If this checkbox is selected, the "from" imports of the same source are combined.
# Selected
from os.path import join, relpath, abspath, dirname, basename
# Not selected
from os.path import join
from os.path import relpath, abspath
from os.path import dirname, basename
The option Join "from" imports with the same source corresponds to the combine_as option of the the utility isort
thanks @labrys
I can't find the rules in official document neither. 😸
Personally I think it would be nice to be able to just add an option for all the styles that allows you to choose case sensitivity.
PyCharm's import settings is closest to Smarkets, but it's sorting is case sensitive. So this PR implements a new style for PyCharm only.
But I'm not sure if it's appropriate to put a specific IDE import style here.
Please leave comment if any question.