pylint

How do I disable pylint unused import error messages in vs code

让人想犯罪 __ 提交于 2019-12-20 17:41:38
问题 How do I disable these error messages from popping up in the problems box in vs code 回答1: As others have said, you can provide a disable argument to disable a specific message. I wanted to elaborate on that. Here is the syntax for disabling multiple messages and for providing multiple arguments , which was not immediately obvious to me from googling it: "python.linting.pylintArgs": [ "--max-line-length=80", "--disable=W0142,W0403,W0613,W0232,R0903,R0913,C0103,R0914,C0304,F0401,W0402,E1101

how to tell pylint to ignore certain imports?

折月煮酒 提交于 2019-12-20 11:42:16
问题 I'm developing software for Windows with Python. I am developing on Linux, and I am using Pylint to check my code. I can't get rid of the error: F| Unable to import '_winreg' This is obvious - Python on Linux does not have this module. So, what do I have to put in my .pylintrc to ignore this error? Thanks in advance, Oz EDIT: Documentation says: :F0401: *Unable to import %r* Used when pylint has been unable to import a module. Now I need to find how to use it ... Partial solution: pylint -

Pylint badge in gitlab

妖精的绣舞 提交于 2019-12-20 10:45:04
问题 Gitlab has functionality to generade badges about build status and coverage percentage. Is it possible to create custom badge to display Pylint results? Or just display this results in README.md? I already have CI job for Pylint 回答1: I have written a python badge generation package that produces badges very visually similar to the main badge services. It is highly flexible, you can import and use in your python code, or run from the command line. I use this in GitLab CI to display pylint and

pylint warning on 'except Exception:'

荒凉一梦 提交于 2019-12-20 10:38:34
问题 For a block like this: try: #some stuff except Exception: pass pylint raises warning W0703 'Catch "Exception"'. Why? 回答1: It's considered good practice to not normally catch the root Exception object, instead of catching more specific ones - for example IOException. Consider if an out of memory exception occurred - simply using "pass" isn't going to leave your programme in a good state. Pretty much the only time you should catch Exception is at the top level of your programme, where you can

visual studio code disable auto wrap long line

ε祈祈猫儿з 提交于 2019-12-20 08:46:38
问题 I use vs code to write python with pylint. When I press ctrl + S (save), the editor wrap a long line into multiple short lines. How to disable the action or configure wrap column count to 120 (default is 80)? I have tried "python.linting.pylintArgs": ["--max-line-length=120"] and "editor.wordWrapColumn": 120 , but didn't work. 回答1: Check your Python formatting provider. "python.formatting.provider": "autopep8" I guess in your case it is not PyLint who keeps wrapping the long lines, but

Pylint showing invalid variable name in output

纵然是瞬间 提交于 2019-12-20 08:34:53
问题 I made a simple python script to post data on a website. #Imports url_to_short = sys.argv[1] post_url = 'https://www.googleapis.com/urlshortener/v1/url' headers = {'Content-Type': 'application/json'} data = {'longUrl': url_to_short} post_data = json.dumps(data) req = urllib2.Request(post_url, post_data, headers) resp = urllib2.urlopen(req) if resp.getcode() == 200: content = json.loads(resp.read()) #Other stuff Now I thought lets check my script for coding standards with pylint tool. My

Why should __all__ only contain string objects?

一世执手 提交于 2019-12-19 11:35:56
问题 Today I came across the following pylint error: invalid-all-object (E0604): Invalid object %r in __all__, must contain only strings Used when an invalid (non-string) object occurs in __all__. And I'm quite curious to why is it considered incorrect to expose objects directly? 回答1: Because it's supposed to be a list of names , not values: If the list of identifiers is replaced by a star ( '*' ), all public names defined in the module are bound in the local namespace for the scope where the

Disable pylint message for a given module or directory

大憨熊 提交于 2019-12-19 06:14:31
问题 Is there a way to disable Pylint's duplicate-code message just for test files? All of the tests in our project are DAMP so the duplicated code is by design. I understand we can add # pylint: disable=duplicate-code throughout our tests, but would rather add some sort of rule that says all files under a test/ folder will have this rule disabled. Is there a way to do this? To be more specific, I'm looking for something different from a 'run it twice' solution (which is what I've already fallen

python-pylint 'C0103:Invalid constant name

可紊 提交于 2019-12-18 12:45:16
问题 I'm confused about the error(s) in this photo: I don't know how to fix them. My program is a Python-Flask web frame. When I use VScode to debug my program, Pylint shows these errors. I know this problem doesn't matter, but it makes me annoyed. How Can I fix it? # -*- coding: utf-8 -*- import sys from flask import Flask from flask_bootstrap import Bootstrap from flask_moment import Moment #from flask_wtf import Form #from wtforms import StringField, SubmitField #from wtforms.validators import

How to run Pylint with PyCharm

大兔子大兔子 提交于 2019-12-18 10:09:16
问题 I want to configure pylint as an external tool on my entire project directory for a python project that I'm working on. I've tried to use the repository as a module with __init__.py and without, and its not working either way. I'm having difficulty setting up pylint to run with PyCharm. I know that I should be running it as an external tool, however the settings confuse me. The authoritative source on their documentation is broken, so I can't check that up either. 回答1: You can set up pylint