pylint

Pylint: Disable specific warnings for specific folder

无人久伴 提交于 2019-12-03 05:59:59
We have a Python project laid out like this: project/ ├── .pylintrc ├── module1.py ├── module2.py └── tests/ ├── test_module1.py └── test_module2.py Our unit and function tests reside in the folder called tests/ . When it comes to tests the pylint warnings missing-docstring , invalid-name and protected-access are not relevant. On the other hand, these warnings are very useful for the actual code in the project. My question is whether it is possible to add ignores for missing-docstring , invalid-name and protected-access in the .pylintrc -file that apply to modules in the tests/ -folder only ?

how to tell pylint to ignore certain imports?

≡放荡痞女 提交于 2019-12-03 04:56:33
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 --disable=F0401 <filename> I am still looking for a way to do via .pylintrc. Just run into this as well

How to run Pylint for all Python files in a directory

落爺英雄遲暮 提交于 2019-12-03 04:43:38
问题 I have find . -iname "*.py" -exec pylint -E {} ;\ and FILES=$(find . -iname "*.py") pylint -E $FILES If I understand correctly, the first command will run pylint for each of the Python files, the second one will run pylint once for all files. I expected that both commands would return the same output, but they return different results. I think this diff is somehow related to imports and F (failure) pylint messages, which occurs when a import fails and is not output by pylint -E. Has someone

Why is the empty dictionary a dangerous default value in Python? [duplicate]

对着背影说爱祢 提交于 2019-12-03 04:39:18
问题 This question already has answers here : “Least Astonishment” and the Mutable Default Argument (31 answers) Python methods: default parameter values are evaluated ONCE (3 answers) Closed 5 years ago . I put empty braces as the default value for an optional argument to a Python function, and pylint (using Sublime package) told me it was dangerous. Can someone explain why this is the case? And is a better alternative to use None instead? 回答1: It's dangerous only if your function will modify the

How to deal with Pylint's “too-many-instance-attributes” message?

做~自己de王妃 提交于 2019-12-03 04:30:54
问题 I have just tried to lint some code with Pylint, and the last remaining error is R0902: too-many-instance-attributes (8/7) I understand the rationale behind limiting the number of instance attributes, but seven seems a bit low. I also realise that the linter should not have the last word. However, I would like to know what I should be doing instead of: def __init__(self, output_file=None, output_dir=None): """ Set the frobnicator up, along with default geometries """ self.margin = 30 self.pos

Pylint to show only warnings and errors

故事扮演 提交于 2019-12-03 04:11:48
问题 I would like to use pylint to check my code but I am only interested in error and warning levels. Is there a way to do that in command line or in pylintrc? I am not interested in filtering given issues (like listing all messages in MESSAGE CONTROL), I just want pylint to ignore all convention and refactor messages. Note: I don't think that's a duplicate of Using Pylint to display error and warnings 回答1: Use the -d / --disable option to turn off the "C" and "R" message classes (convention and

Pylint invalid constant name

橙三吉。 提交于 2019-12-03 03:25:29
问题 I'm receiving a Pylint error regarding my constant: MIN_SOIL_PARTICLE_DENS (invalid name). Any ideas why this constant is wrong? Here's my full function: def bulk_density(clay, sand, organic_matter): MIN_SOIL_PARTICLE_DENS = 2.65 x1 = (0.078 + 0.278 * sand + 0.034 * clay + 0.022 * organic_matter - 0.018 * sand * organic_matter - 0.027 * clay * organic_matter - 0.584 * sand * clay) x2 = -0.107 + 1.636 * x1 field_capacity = vol_water_content_33_j_kg(clay, sand, organic_matter)#m3/m3 sat_water

Visual Studio Code - removing pylint

可紊 提交于 2019-12-03 03:06:39
Simple question - but any steps on how to remove pylint from a Windows 10 machine with Python 3.5.2 installed. I got an old version of pylint installed that's spellchecking on old Python 2 semantics and it's bugging the heck out of me when the squigglies show up in Visual Studio Code. Mahmoud Ayman open the workspace settings file (select File > Preferences > Settings, then locate Python configuration) and edit this line as "python.linting.pylintEnabled": false then save the file. If you just want to disable pylint then the updated VSCode makes it much more easier. Just hit CTRL + SHIFT + P >

Python - Should I put my helper functions inside or outside the class? [closed]

折月煮酒 提交于 2019-12-03 02:34:52
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 12 months ago . In Python, if some methods of a class need a helper function, but the helper function itself doesn't use anything in the class, should I put the helper function inside or outside the class? I tried putting it inside but PyLint was complaining that this function could have

Pylint can't find SQLAlchemy query member

老子叫甜甜 提交于 2019-12-03 02:12:45
问题 I have a Flask (v0.10.1) application using Flask-SQLAlchemy (v2.0) and I'm trying to configure Pylint to check it. Running with Python 3.4.2. First error was: Instance of 'SQLAlchemy' has no 'Table' member (no-member) And I fixed this one ignoring the check for member attributes on SQLAlchemy: ignored-classes=SQLAlchemy But I'm having a problem with the query member on entities: Class 'UserToken' has no 'query' member (no-member) Is there any way to fix this issue without having to ignore no