I would really like to know if there is some Extension in Visual Studio Code or other means that could help identify and remove any unused imports.
I have quite a large number of imports like this and it’s getting close to 40 lines. I know some of them aren’t in use, the problem is removing them safely.
JavaScript
x
8
1
from django.core.mail import EmailMultiAlternatives, send_mail
2
from django.template.loader import render_to_string
3
from django.utils.html import strip_tags
4
from rest_framework import routers, serializers, viewsets, status
5
from rest_framework.views import APIView
6
from rest_framework.response import Response
7
from django.contrib.auth.models import User
8
Advertisement
Answer
Go to the User Settings json file and add the following:
JavaScript
1
5
1
"python.linting.pylintEnabled": true,
2
"python.linting.pylintArgs": [
3
"--enable=W0614"
4
]
5
This should remove the unused python imports automatically.
More suggestions here: How can I check for unused import in many Python files?