Detect unused imports in visual studio code for python 3?












0















I am subscribing to this issue about warning unused imports for python in visual studio code.



I am not particular about whether it's squiggle or gray out. But I am not certain if this feature is available based on the discussion or there's a workaround using a linter.



I am okay either way so long some detection is available.



I am using pylint as linter for now. Would be okay to use other linter so long I can detect unused imports.



And I do not want to auto remove unused imports.



This is what I see despite turning on pylint. I have purposely added an unused import. And I am not seeing any problems in this file.



enter image description here










share|improve this question





























    0















    I am subscribing to this issue about warning unused imports for python in visual studio code.



    I am not particular about whether it's squiggle or gray out. But I am not certain if this feature is available based on the discussion or there's a workaround using a linter.



    I am okay either way so long some detection is available.



    I am using pylint as linter for now. Would be okay to use other linter so long I can detect unused imports.



    And I do not want to auto remove unused imports.



    This is what I see despite turning on pylint. I have purposely added an unused import. And I am not seeing any problems in this file.



    enter image description here










    share|improve this question



























      0












      0








      0








      I am subscribing to this issue about warning unused imports for python in visual studio code.



      I am not particular about whether it's squiggle or gray out. But I am not certain if this feature is available based on the discussion or there's a workaround using a linter.



      I am okay either way so long some detection is available.



      I am using pylint as linter for now. Would be okay to use other linter so long I can detect unused imports.



      And I do not want to auto remove unused imports.



      This is what I see despite turning on pylint. I have purposely added an unused import. And I am not seeing any problems in this file.



      enter image description here










      share|improve this question
















      I am subscribing to this issue about warning unused imports for python in visual studio code.



      I am not particular about whether it's squiggle or gray out. But I am not certain if this feature is available based on the discussion or there's a workaround using a linter.



      I am okay either way so long some detection is available.



      I am using pylint as linter for now. Would be okay to use other linter so long I can detect unused imports.



      And I do not want to auto remove unused imports.



      This is what I see despite turning on pylint. I have purposely added an unused import. And I am not seeing any problems in this file.



      enter image description here







      python visual-studio-code






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 2:04







      Kim Stacks

















      asked Nov 18 '18 at 3:32









      Kim StacksKim Stacks

      4,4022097204




      4,4022097204
























          2 Answers
          2






          active

          oldest

          votes


















          1














          The Python extension for VS Code does not support warning about unused imports in its language server yet. But if you want Pylint to warn you, create a .pylintrc and and turn on the W0611 warning.






          share|improve this answer
























          • Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

            – Kim Stacks
            Nov 20 '18 at 0:38











          • Did you check you get the warning when running the linters manually from the terminal?

            – Brett Cannon
            Nov 20 '18 at 20:38











          • Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

            – Kim Stacks
            Nov 21 '18 at 2:00













          • If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

            – Brett Cannon
            Nov 21 '18 at 20:48



















          1














          Update/create VSCode user settings



          "python.linting.pylintEnabled": true,
          "python.linting.pylintArgs": [
          "--enable=W0614"
          ]


          this works for me in Python 3.6.7






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357649%2fdetect-unused-imports-in-visual-studio-code-for-python-3%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            The Python extension for VS Code does not support warning about unused imports in its language server yet. But if you want Pylint to warn you, create a .pylintrc and and turn on the W0611 warning.






            share|improve this answer
























            • Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

              – Kim Stacks
              Nov 20 '18 at 0:38











            • Did you check you get the warning when running the linters manually from the terminal?

              – Brett Cannon
              Nov 20 '18 at 20:38











            • Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

              – Kim Stacks
              Nov 21 '18 at 2:00













            • If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

              – Brett Cannon
              Nov 21 '18 at 20:48
















            1














            The Python extension for VS Code does not support warning about unused imports in its language server yet. But if you want Pylint to warn you, create a .pylintrc and and turn on the W0611 warning.






            share|improve this answer
























            • Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

              – Kim Stacks
              Nov 20 '18 at 0:38











            • Did you check you get the warning when running the linters manually from the terminal?

              – Brett Cannon
              Nov 20 '18 at 20:38











            • Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

              – Kim Stacks
              Nov 21 '18 at 2:00













            • If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

              – Brett Cannon
              Nov 21 '18 at 20:48














            1












            1








            1







            The Python extension for VS Code does not support warning about unused imports in its language server yet. But if you want Pylint to warn you, create a .pylintrc and and turn on the W0611 warning.






            share|improve this answer













            The Python extension for VS Code does not support warning about unused imports in its language server yet. But if you want Pylint to warn you, create a .pylintrc and and turn on the W0611 warning.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 19 '18 at 20:38









            Brett CannonBrett Cannon

            1,7561129




            1,7561129













            • Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

              – Kim Stacks
              Nov 20 '18 at 0:38











            • Did you check you get the warning when running the linters manually from the terminal?

              – Brett Cannon
              Nov 20 '18 at 20:38











            • Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

              – Kim Stacks
              Nov 21 '18 at 2:00













            • If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

              – Brett Cannon
              Nov 21 '18 at 20:48



















            • Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

              – Kim Stacks
              Nov 20 '18 at 0:38











            • Did you check you get the warning when running the linters manually from the terminal?

              – Brett Cannon
              Nov 20 '18 at 20:38











            • Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

              – Kim Stacks
              Nov 21 '18 at 2:00













            • If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

              – Brett Cannon
              Nov 21 '18 at 20:48

















            Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

            – Kim Stacks
            Nov 20 '18 at 0:38





            Thanks I turned it on but to no avail. I have both pep8 and Pylint on in the workspace settings for vs code

            – Kim Stacks
            Nov 20 '18 at 0:38













            Did you check you get the warning when running the linters manually from the terminal?

            – Brett Cannon
            Nov 20 '18 at 20:38





            Did you check you get the warning when running the linters manually from the terminal?

            – Brett Cannon
            Nov 20 '18 at 20:38













            Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

            – Kim Stacks
            Nov 21 '18 at 2:00







            Oh so it doesn't auto show up in the vs code itself? I have added a screenshot as well.

            – Kim Stacks
            Nov 21 '18 at 2:00















            If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

            – Brett Cannon
            Nov 21 '18 at 20:48





            If the linters tell us there's something to warn about then we show the warning. My point is that if the linters won't tell you when run manually then the extension won't warn you either. Basically the extension just executes the linters on your behalf and parses the output; nothing fancy, which typically means that if we don't show it then the linter didn't report it.

            – Brett Cannon
            Nov 21 '18 at 20:48













            1














            Update/create VSCode user settings



            "python.linting.pylintEnabled": true,
            "python.linting.pylintArgs": [
            "--enable=W0614"
            ]


            this works for me in Python 3.6.7






            share|improve this answer




























              1














              Update/create VSCode user settings



              "python.linting.pylintEnabled": true,
              "python.linting.pylintArgs": [
              "--enable=W0614"
              ]


              this works for me in Python 3.6.7






              share|improve this answer


























                1












                1








                1







                Update/create VSCode user settings



                "python.linting.pylintEnabled": true,
                "python.linting.pylintArgs": [
                "--enable=W0614"
                ]


                this works for me in Python 3.6.7






                share|improve this answer













                Update/create VSCode user settings



                "python.linting.pylintEnabled": true,
                "python.linting.pylintArgs": [
                "--enable=W0614"
                ]


                this works for me in Python 3.6.7







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 7 at 21:19









                viruviru

                160110




                160110






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357649%2fdetect-unused-imports-in-visual-studio-code-for-python-3%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Academy of Television Arts & Sciences

                    L'Équipe

                    1995 France bombings