Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution of false alarm Unable to import'xxx'pylint in VScode

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

The solution to the false alarm of Unable to import'xxx'pylint in VScode. In view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The solution of false positive Unable to import 'xxx' pylint (import-error) in VScode

When the sibling directory invocation module is made in vscode

Referencing the method in public/Loginmodel.py in test_case/veryInfoUpload.py), the following phenomena occur:

1. Add the _ _ init__.py file to public to make it a package. Using the features of the package, there is no problem to import directly with the package in the module maintest.py of the same level of public: from public.Loginmodel import veryLogin,veryLogout;, but it is wrong to call the module in the sibling directory of public with the package, and all kinds of attempts will not work.

2, define pubic as a package, can not solve our problem, can only use the second way, we will append the public directory to the sys.path (sys is a python module, need to import), and then guide the package: from Loginmodel import veryLogin,veryLogout; at this time to run the script can normally import the method in the module, but vscode prompts the problem of Vscode pylint unable to import.

After analysis, it is because before adding sys.path, vscode static analysis cannot be imported into the module under public, but after the code runs, the import is correct, so the hint of vscode is problematic and marked in red, which is very uncomfortable for us with obsessive-compulsive disorder. Let's take a look at how to get rid of this red tip.

Click File-> preferences-> Settings in vscode, and enter: pylintArgs in the search box

Click the add item in the search results Python > Linting:Pylint Args, add-errors-only and-disable=E0401 respectively, save, exit the settings, and restart vscode, and the above error prompt will be gone.

So much for the solution to the problem of false positives in Unable to import'xxx'pylint in VScode. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report