I was using pylint --list-msgs and one of the warnings I got was this one:
:using-final-decorator-in-unsupported-version (W2602): *typing.final is not supported by all versions included in the py-version setting* Used when the py-version set by the user is lower than 3.8 and pylint encounters a ``typing.final`` decorator.
I couldn't understand this warning because my version in .pylintrc and in the project is: 3.11, the only reference to typing in the project is this: from typing import TypedDict
I hope first is not receive this warning, because the project don't have reference with this warning, and if possible, understand the reason for the warning
When you launch pylint --list-msgs pylint is displaying a list of all its messages, it's going to always be the same for everyone and is not related to your code. Here's the doc for this message if you want more detail about it : https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/using-final-decorator-in-unsupported-version.html
Related
When running ipynbs in VS Code, I've started noticing Pylance warnings on standard library imports. I am using a conda virtual environment, and I believe the warning is related to that. An example using the glob library reads:
"env\Lib\glob.py" is overriding the stdlib "glob" modulePylance(reportShadowedImports)
So far my notebooks run as expected, but I am curious if this warning is indicative of poor layout or is just stating the obvious more of an "FYI you are not using the base install of python".
I have turned off linting and the problem stills persists. And almost nothing returns from my searches of the error "reportShadowedImports".
The reason you find nothing by searching is because this check has just been implemented recently (see Github). I ran into the same problem as you because code.py from Micropython/Circuitpython also overrides the module "code" in stdlib.
The solution is simple, though you then loose out on this specific check. Just add reportShadowedImports to your pyright config. For VS Code, that would be adding it to .vscode/settings.json:
{
"python.languageServer": "Pylance",
[...]
"python.analysis.diagnosticSeverityOverrides": {
"reportShadowedImports": "none"
},
[...]
}
I have the following method
def foo(bar):
print("hello world")
Edit: Running pylint in VSCode
[expected behavior]
pylint highlights 'bar' as an unused variable
[Actual Behaviour]
From VScode output
##########Linting Output - pylint##########
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
I have no additional pylint config setup
It turns out there is a setting in VSCode that enforces minimal checkers
Python › Linting: Pylint Use Minimal Checkers
I found this in pylint documentation:
possibly-unused-variable (W0641):
Possibly unused variable %r Used when a variable is defined but might not be used. The possibility comes from the fact that locals() might be used, which could consume or not the said variable
In your case, probably because you haven't use the bar argument inside your function. If you are not using it, just remove it for a cleaning code.
Check the oficial VS Code documentation about linting if you want to change this settings.
I am using pylint for code linting (inside VS Code with pylint 2.3.1, astroid 2.2.5, Python 3.6.2).
The behavior can be reproduced with the following snippet:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from http import HTTPStatus
print(HTTPStatus.NOT_ACCEPTABLE.phrase)
Linting this snippet by calling
$ pylint snippet.py
gives the following error message:
E1101: Instance of 'NOT_ACCEPTABLE' has no 'phrase' member (no-member)
However, I think .phrase is a member of the given instance since the code is working, prints the desired result and .phrase is referenced in the docs. Which leads to the assumption that the error message is a false positive.
I then had a look at the pylint configuration options in its own documentation and in the VS Code docs and generated a .pylintrc file by executing
pylint --generate-rcfile > .pylintrc
Inside this configuration file I was able to find the following line:
enable=c-extension-no-member
Commenting out this line and thus disabling the c-extension-no-member checks, the false positive E1101 error message is suppressed. However, I am still wondering whether this is just a workaround or a real false positive, since it disables all c-extension-no-member checks and seems to be unsuitable for a general approach. For sure, one can specify specific modules to ignore on performing the checks, but I just want to know the reason for this error message.
I use VS Code Version 1.19.3 with Python 2.7 on Windows.
Recently pylint (code analyzer) shown an error message
"E1601:print statement used"
But I don't know why! Can someone help me?
The print statement is correct as per my knowledge!
Is it a bug or a feature is missing?
Greetings niesel
The warning originates from Pylint, which is a very helpful tool for a dynamic language with loose syntax like Python. Since you are programming in Python 2.x where print is perfectly valid, I suggest you put a file in the root of your repo named .pylintrc and use it to configure Pylint.
To disable the print warning and leave everything else to the default, enter these two lines in your .pylintrc file:
[MESSAGES CONTROL]
disable=print-statement
You will also need to tell Visual Studio Code to use your configuration file by opening your workspace or user settings and add this:
{
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--rcfile=/path/to/.pylintrc"
]
}
More options
To get a good idea of available configuration options open a terminal/prompt and run this command to generate a sample configuration file:
pylint --generate-rcfile > sample_pylintrc
The problem is, that changing from print statement to print function doesn't help much. So it seems, that it is some bug in VS Code Python module (2018.1 (01 Feb 2018)), as after this update I've found the same problem in my VS Code within my old projects
I've found reffered bug on their github
PS: vscode-python has changed pylint options since 2018.1. In order to return old behavior you may disable python.linting.pylintUseMinimalCheckers option for the workspace or for the userspace.
it's not an error per-se, it's just PyLint complaining about those legacy statements. PyLint will also complain about missing spaces before commas, those kind of style errors.
PyLint is there to warn you about possible problems. Your code will break when running python 3, so it warns you before it happens.
Note that print is a statement in python 2.x (which explains the message), and became a function in python 3.x.
Fix it by changing to:
print("test")
Since it's not a tuple, it works fine and does exactly the same for all versions of python, and PyLint will stop complaining.
you can also get rid of PyLint altogether: Windows 10 - Visual Studio Code - removing pylint (not sure if it's a good idea)
When I run pylint locally, I don't see the warning. I really would not expect to see the warning at all. This occurs on at least 2 different versions of jenkins, currently running the latest version 1.576. The warning is shown in the UI using the Violations plug-in version 0.7.11 which is the latest.
This is the line of code that is tagged in the warning:
request.context.__parent__ = report # pylint: disable=W0201
And the warning it gives is 5 copies of W0201
This Warning was also disabled above in the code here:
#pylint: disable=R0901, R0904, R0914, W0201
Neither approach seems to have any effect.
Perhaps the pylintrc file is different between the machines/users.
Try copying your local ~/.pylintrc to your jenkins home folder.
Details for this are in here:
How do I disable a Pylint warning?