Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pylint throws error "TypeError: Converting circular structure to JSON" when using pylint + any combination of other linters. #3700

Closed
crhan opened this issue Dec 14, 2018 · 8 comments
Labels
area-linting bug Issue identified by VS Code Team member as probable bug

Comments

@crhan
Copy link

crhan commented Dec 14, 2018

Environment data

  • VS Code version: 1.30.0
  • Extension version (available under the Extensions sidebar): 2018.12.0
  • OS and version: MacOS 10.14.2 (18C54)
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.6.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions:
pylint 2.2.2
astroid 2.0.4
Python 3.6.6 (default, Sep 17 2018, 16:44:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]

Extension infomation:

Name: Python
Id: ms-python.python
Description: Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, and more.
Version: 2018.12.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python

Expected behaviour

Pylint work as it was

Actual behaviour

image

Steps to reproduce:

  1. Upgrade vscode python extension to 2018.12.0
  2. open any python file

Logs

Starting Microsoft Python language server.
Linting with mypy failed.
TypeError: Converting circular structure to JSON
Linting with pylint failed.
TypeError: Converting circular structure to JSON
##########Linting Output - bandit##########
94,0,MEDIUM,B104:Possible binding to all interfaces.
173,0,LOW,B101:Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
188,0,LOW,B101:Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
189,0,LOW,B101:Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Microsoft Python Language Server version 0.1.72.0
Initializing for /Users/ruohan.chen/.pyenv/versions/vpc_test-3.6.6/bin/python

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

[Extension Host] [modelines] could not find TextEditor
console.ts:134 [Extension Host] Python Extension: There was an error in running the linter mypy TypeError: Converting circular structure to JSON
	at JSON.stringify (<anonymous>)
	at module.exports.t.ProcessService.getDefaultOptions (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:315447)
	at module.exports.t.ProcessService.exec (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:314478)
	at p.<anonymous> (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:326851)
	at Generator.next (<anonymous>)
	at module.exports.i (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:324782)
	at new Promise (<anonymous>)
	at module.exports.i (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:324559)
	at p.execModule (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:326765)
	at u.<anonymous> (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:328639)
	at Generator.next (<anonymous>)
	at s (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:327651)
	at <anonymous>
t.log @ console.ts:134
notificationsAlerts.ts:40 There was an error in running the linter 'mypy'
t.onDidNotificationChange @ notificationsAlerts.ts:40
console.ts:134 [Extension Host] Python Extension: There was an error in running the linter pylint TypeError: Converting circular structure to JSON
	at JSON.stringify (<anonymous>)
	at module.exports.t.ProcessService.getDefaultOptions (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:315447)
	at module.exports.t.ProcessService.exec (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:314478)
	at p.<anonymous> (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:326851)
	at Generator.next (<anonymous>)
	at module.exports.i (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:324782)
	at new Promise (<anonymous>)
	at module.exports.i (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:324559)
	at p.execModule (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:326765)
	at u.<anonymous> (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:328639)
	at Generator.next (<anonymous>)
	at s (/Users/ruohan.chen/.vscode/extensions/ms-python.python-2018.12.0/out/client/extension.js:83:327651)
	at <anonymous>
t.log @ console.ts:134
notificationsAlerts.ts:40 There was an error in running the linter 'pylint'
t.onDidNotificationChange @ notificationsAlerts.ts:40
console.ts:134 [Extension Host] [modelines] setting editor options: {}
@Gr1N
Copy link

Gr1N commented Dec 14, 2018

Same issue

@d3r3kk d3r3kk changed the title linter error in version 2018.12.0 Pylint throws error "TypeError: Converting circular structure to JSON" when using pylint + any combination of other linters. Dec 14, 2018
@d3r3kk d3r3kk added bug Issue identified by VS Code Team member as probable bug area-linting needs PR labels Dec 14, 2018
@d3r3kk
Copy link

d3r3kk commented Dec 14, 2018

I verified this bug and found that you can reproduce this issue with pylint + any combination of other linters being used in tandem with pylint, it is not necessary to use all other linters described.

@matthieugouel
Copy link

matthieugouel commented Dec 14, 2018

I have the same problem using flake8 and mypy which both fails the same way (but bandit not) but I don't use pylint. Only on version 2018.12.0.

Starting Jedi Python language engine.
Linting with mypy failed.
TypeError: Converting circular structure to JSON
Linting with flake8 failed.
TypeError: Converting circular structure to JSON
##########Linting Output - bandit##########

@pierrecregut
Copy link

In src/client/common/process/proc.ts:

    private getDefaultOptions<T extends (ShellOptions | SpawnOptions)>(options: T) : T {
        const execOptions = options as SpawnOptions;
        const defaultOptions = JSON.parse(JSON.stringify(options));

It fails because options has a token field that contains a circular structure. A crude patch:

        const safeOptions = Object.assign({}, options);
        delete safeOptions.token
        const defaultOptions = JSON.parse(JSON.stringify(safeOptions));

@iansan5653
Copy link

iansan5653 commented Dec 14, 2018

I just started having the same problem this morning.

Starting Microsoft Python language server.
##########Linting Output - bandit##########
Linting with flake8 failed.
TypeError: Converting circular structure to JSON
Linting with flake8 failed.
TypeError: Converting circular structure to JSON
##########Linting Output - bandit##########
Linting with flake8 failed.
...

@iansan5653
Copy link

It looks like PR #3702 would fix this

@iansan5653
Copy link

A temporary fix is to disable all but one linter. In my case, setting python.linting.banditEnabled to false fixed the problem (but of course then you're not using your other linter, so it's just a quick fix to avoid the error until it's patched).

@d3r3kk
Copy link

d3r3kk commented Dec 14, 2018

Thanks for the clarification @matthieugouel, and the legwork @pierrecregut!

(It was a sleepless night at 3am for me when I made my observation, so awesome to wake up to this info!)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

7 participants