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

Plain text outputs to stdout invalidate the non-text outputs formatting #6597

Closed
yilei opened this issue May 12, 2022 · 1 comment · Fixed by #6598
Closed

Plain text outputs to stdout invalidate the non-text outputs formatting #6597

yilei opened this issue May 12, 2022 · 1 comment · Fixed by #6598
Labels
Milestone

Comments

@yilei
Copy link
Contributor

yilei commented May 12, 2022

Bug description

https://github.com/PyCQA/pylint/blob/d668f641ef5d5794f912cd5a23292bf493290905/pylint/utils/ast_walker.py#L98 prints the exception error message to stdout, making the output invalid.

Configuration

No response

Command used

$ cat myfile.py
def myfunc():
  try:
    @property
    def myfunc():
      return None
  except TypeError:
    pass

  @myfunc.setter
  def myfunc():
    pass

  return myfunc()
$ pylint --output-format=json myfile.py 2>/dev/null

Pylint output

Exception on node <Call l.13 at 0x7ff8da87f3a0> in file 'myfile.py'
[
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 2,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 2 spaces, expected 4",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 3,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 4 spaces, expected 8",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 4,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 4 spaces, expected 8",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 5,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 6 spaces, expected 12",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 6,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 2 spaces, expected 4",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 7,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 4 spaces, expected 8",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 9,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 2 spaces, expected 4",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 10,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 2 spaces, expected 4",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 11,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 4 spaces, expected 8",
        "message-id": "W0311"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "",
        "line": 13,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "bad-indentation",
        "message": "Bad indentation. Found 2 spaces, expected 4",
        "message-id": "W0311"
    },
    {
        "type": "convention",
        "module": "myfile",
        "obj": "",
        "line": 1,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "missing-module-docstring",
        "message": "Missing module docstring",
        "message-id": "C0114"
    },
    {
        "type": "convention",
        "module": "myfile",
        "obj": "myfunc",
        "line": 1,
        "column": 0,
        "endLine": 1,
        "endColumn": 10,
        "path": "myfile.py",
        "symbol": "missing-function-docstring",
        "message": "Missing function or method docstring",
        "message-id": "C0116"
    },
    {
        "type": "warning",
        "module": "myfile",
        "obj": "myfunc.myfunc",
        "line": 4,
        "column": 4,
        "endLine": 4,
        "endColumn": 14,
        "path": "myfile.py",
        "symbol": "redefined-outer-name",
        "message": "Redefining name 'myfunc' from outer scope (line 1)",
        "message-id": "W0621"
    },
    {
        "type": "fatal",
        "module": "myfile",
        "obj": "",
        "line": 1,
        "column": 0,
        "endLine": null,
        "endColumn": null,
        "path": "myfile.py",
        "symbol": "astroid-error",
        "message": "myfile.py: Fatal error while checking 'myfile.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '~/.cache/pylint/pylint-crash-2022-05-12-14.txt'.",
        "message-id": "F0002"
    }
]


### Expected behavior

pylint should write valid json to stdout

### Pylint version

```shell
pylint 2.13.8
astroid 2.11.4
Python 3.9.10 (main, Mar 16 2022, 06:54:08)
[GCC 11.2.0]

OS / Environment

No response

Additional dependencies

No response

@yilei yilei added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label May 12, 2022
@yilei
Copy link
Contributor Author

yilei commented May 12, 2022

I have an upcoming PR to address this.

@jacobtylerwalls jacobtylerwalls added Bug 🪲 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels May 12, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.14.0 milestone May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants