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

Sort Imports command not following PEP8 strictly #123707

Closed
everspader opened this issue May 12, 2021 · 3 comments
Closed

Sort Imports command not following PEP8 strictly #123707

everspader opened this issue May 12, 2021 · 3 comments
Assignees
Labels
*caused-by-extension Issue identified to be caused by an extension

Comments

@everspader
Copy link

  • VS Code Version: 1.56.0
  • OS Version: Ubuntu 20.04

Steps to Reproduce:

  1. Write any script that has standard library imports, third-party imports, and your local packages imports.
  2. Right-click in the script and select Sort Imports

Let's say I write the following imports when creating a Django app.

import os
import functools
from rest_framework import viewsets
from django.db import models
from myapp.models import Upload

After I run the Sort Imports command, the output is:

import functools
import os

from django.db import models
from myapp.models import Upload
from rest_framework import viewsets

This means VSCode is sorting the third-party imports together with my local app imports alphabetically. However, according to the imports section on PEP8, there should be a blank line between:

  1. Standard library imports.
  2. Related third-party imports.
  3. Local application/library-specific imports.

Therefore, the desired output would be:

import functools
import os

from django.db import models
from rest_framework import viewsets

from myapp.models import Upload

Does this issue occur when all extensions are disabled?: Yes

@vscodebot
Copy link

vscodebot bot commented May 12, 2021

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@mjbvz
Copy link
Collaborator

mjbvz commented May 12, 2021

/extPython

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*caused-by-extension Issue identified to be caused by an extension
Projects
None yet
Development

No branches or pull requests

3 participants
@mjbvz @everspader and others