question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

print statement is highlighted by pylint

See original GitHub issue

Environment data

VS Code version: 1.19.3 Python Extension version: 2018.1 Python Version: 2.7, 3.5 OS and version: OS independent

Actual behavior

pylint marks print statement and print() function are marked as error on both python 2.7 and python 3.5. This behavior appeared just after module upgrade to 2018.1

Expected behavior

pylint shouldn’t mark error if using print() function on any python version and print statement on python 2.7

Steps to reproduce:

  • create new .py file
  • enter print("Hello, world!")
  • save file Screenshot

Logs

Output from Python output panel

[pylint]E1601:print statement used (1, 1)

Output from Console window (Help->Developer Tools menu)

console.ts:123 [Extension Host] Python Extension: Failed to get conda info from conda null
t.log @ console.ts:123
console.ts:123 [Extension Host] (node:16735) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:26 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
MikhailArkhipovcommented, Feb 14, 2018

This change is by design since many people don’t care about whitespace or styling. In many editors these kind of reports are off by default. There is a setting though:

pylintUseMinimalCheckers

You can set it to false and the arguments you mentioned won’t be passed to pylint.

2reactions
noonedeadpunkcommented, Feb 7, 2018

But it seems, that according to pylint, this message should be printed only if print is used as the statement, while it marks as an error while using print as a function.

Moreover, I couldn’t reproduce this with system pylint (which is installed on the same machine, as the affected VS Code):

dimar@SVTech-Workstation:~/Documents/Python$ /usr/bin/pylint --version
No config file found, using default configuration
pylint 1.5.2, 
astroid 1.4.4
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609]
dimar@SVTech-Workstation:~/Documents/Python$ /usr/bin/pylint test.py
No config file found, using default configuration
************* Module test
C:  1, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C:  1, 0: Missing module docstring (missing-docstring)


Report
======
1 statements analysed.

Statistics by type
------------------

+---------+-------+-----------+-----------+------------+---------+
|type     |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module   |1      |1          |=          |0.00        |0.00     |
+---------+-------+-----------+-----------+------------+---------+
|class    |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+
|method   |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+
|function |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+



Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |1      |50.00 |NC       |NC         |
+----------+-------+------+---------+-----------+
|docstring |0      |0.00  |NC       |NC         |
+----------+-------+------+---------+-----------+
|comment   |0      |0.00  |NC       |NC         |
+----------+-------+------+---------+-----------+
|empty     |1      |50.00 |NC       |NC         |
+----------+-------+------+---------+-----------+



Duplication
-----------

+-------------------------+------+---------+-----------+
|                         |now   |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines      |0     |NC       |NC         |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |NC       |NC         |
+-------------------------+------+---------+-----------+



Messages by category
--------------------

+-----------+-------+---------+-----------+
|type       |number |previous |difference |
+===========+=======+=========+===========+
|convention |2      |0        |+2.00      |
+-----------+-------+---------+-----------+
|refactor   |0      |0        |=          |
+-----------+-------+---------+-----------+
|warning    |0      |0        |=          |
+-----------+-------+---------+-----------+
|error      |0      |1        |-1.00      |
+-----------+-------+---------+-----------+



Messages
--------

+-------------------+------------+
|message id         |occurrences |
+===================+============+
|superfluous-parens |1           |
+-------------------+------------+
|missing-docstring  |1           |
+-------------------+------------+



Global evaluation
-----------------
Your code has been rated at -10.00/10

dimar@SVTech-Workstation:~/Documents/Python$

And if I replace print() with a statement, only “Missing module docstring (missing-docstring)” notification will stay. So this is possible only if the module uses it’s own pylint, which is different version from the system one.

It seems, that it’s my fault about reporting problem for python3 - pylint just hadn’t re-read the file after changing Python version. So this problem is referenced only to python2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code shows an error message at print statement in python ...
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!
Read more >
Pylint output - Pylint 2.16.0-dev documentation
The simplest way to output to a file is with the --output=<filename> option. ... You can change this by passing pylint the --output-format=<value>...
Read more >
Print All Pylint Warning Codes - seanwasere
Used when a word in docstring is not spelled correctly. :invalid-characters-in-docstring (C0403): *Invalid characters %r in a docstring* Used when a word in ......
Read more >
Your Guide to the Python print() Function
In this step-by-step tutorial, you'll learn about the print() function in Python and discover some of its lesser-known features.
Read more >
Linting Python in Visual Studio Code
To enable linters, open the Command Palette (Ctrl+Shift+P) and select the Python: Select Linter command. The Select Linter command adds "python.linting.<linter> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found