Skip to content

Conversation

@lithammer
Copy link

@lithammer lithammer commented Sep 29, 2021

This fixes an issue when the error text gets truncated because of project local settings. As you can see from the example below, the output with --pretty is wrapped (at 80 chars?) when piped.

The wrapped lines are truncated from the error message.

$ cat > pyproject.toml <<<EOF
[tool.mypy]
pretty = true
EOF

$ cat > foobar.py <<<
def foobar(a: int):
    pass

foobar("123")
EOF

$ mypy foobar.py
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
    foobar("123")
           ^
Found 1 error in 1 file (checked 1 source file)

$ mypy foobar.py | cat
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str";
expected "int"
    foobar("123")
           ^
Found 1 error in 1 file (checked 1 source file)

$ mypy --no-pretty foobar.py
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
Found 1 error in 1 file (checked 1 source file)

$ mypy --no-pretty foobar.py | cat
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
Found 1 error in 1 file (checked 1 source file)

Without --no-pretty:

Screenshot 2021-09-29 at 09 45 51

With --no-pretty:

Screenshot 2021-09-29 at 09 46 20

Fixes #16836

"--ignore-missing-imports",
"--show-column-numbers"
"--show-column-numbers",
"--no-pretty"
Copy link
Author

@lithammer lithammer Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For similar reasons it would probably be nice to add --no-error-summary and maybe --hide-error-context as well.

@karthiknadig
Copy link
Member

@lithammer Thanks for the PR. Can you create a bug for this issue? and add a news item based on that issue number. Create a file <issue-number>.md under news/2 Fixes with content like:

<change log comment for this fix>.
(thanks [Peter Lithammer](https://github.com/lithammer))

For adding --no-error-summary and --hide-error-context, once you create the issue we can discuss if it should be added.

@lithammer
Copy link
Author

lithammer commented Oct 5, 2021

Thanks for reviewing. I had a look at existing issues and it would seem that adding --no-pretty would also fix this issue:

Should I create a news item for that as well? Or should I perhaps just re-use that issue instead of creating my own?

@karthiknadig
Copy link
Member

Yes you can use #16836 as the news file.

@ghost
Copy link

ghost commented Oct 5, 2021

CLA assistant check
All CLA requirements met.

This fixes an issue when the error text gets truncated because of
project local settings. As you can see from the example below, the
output with `--pretty` is wrapped (at 80 chars?) when piped.

The wrapped lines are truncated from the error message.

```console
$ cat > pyproject.toml <<<EOF
[tool.mypy]
pretty = true
EOF

$ cat > foobar.py <<<
def foobar(a: int):
    pass

foobar("123")
EOF

$ mypy foobar.py
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
    foobar("123")
           ^
Found 1 error in 1 file (checked 1 source file)

$ mypy foobar.py | cat
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str";
expected "int"
    foobar("123")
           ^
Found 1 error in 1 file (checked 1 source file)

$ mypy --no-pretty foobar.py
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
Found 1 error in 1 file (checked 1 source file)

$ mypy --no-pretty foobar.py | cat
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
Found 1 error in 1 file (checked 1 source file)
```
@lithammer
Copy link
Author

Yes you can use #16836 as the news file.

Done!

@lithammer
Copy link
Author

lithammer commented Oct 6, 2021

Error: "package.json" was edited but "package-lock.json" was not (the "skip package*.json" label can be used to pass this check)

Not sure what the deal is with this failing check... 🤷‍♂️ Tried to rebase, but no bueno.

@karthiknadig karthiknadig added the skip package*.json package.json and package-lock.json don't both need updating label Oct 6, 2021
@karthiknadig
Copy link
Member

That is just a check to ensure we have not missed any package update in package lock. Cleared it with "skip package*.json"

@lithammer
Copy link
Author

Anything more you need me to do?

@karthiknadig
Copy link
Member

@lithammer nothing for now. We are doing some repo maintenance, we will merge this soon.

@karthiknadig karthiknadig merged commit 3ca8a41 into microsoft:main Oct 14, 2021
@lithammer lithammer deleted the mypy-no-pretty branch October 15, 2021 13:53
wesm pushed a commit to posit-dev/positron that referenced this pull request Mar 28, 2024
…python#17564)

This fixes an issue when the error text gets truncated because of
project local settings. As you can see from the example below, the
output with `--pretty` is wrapped (at 80 chars?) when piped.

The wrapped lines are truncated from the error message.

```console
$ cat > pyproject.toml <<<EOF
[tool.mypy]
pretty = true
EOF

$ cat > foobar.py <<<
def foobar(a: int):
    pass

foobar("123")
EOF

$ mypy foobar.py
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
    foobar("123")
           ^
Found 1 error in 1 file (checked 1 source file)

$ mypy foobar.py | cat
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str";
expected "int"
    foobar("123")
           ^
Found 1 error in 1 file (checked 1 source file)

$ mypy --no-pretty foobar.py
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
Found 1 error in 1 file (checked 1 source file)

$ mypy --no-pretty foobar.py | cat
foobar.py:5: error: Argument 1 to "foobar" has incompatible type "str"; expected "int"
Found 1 error in 1 file (checked 1 source file)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip package*.json package.json and package-lock.json don't both need updating

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no visual indication of mypy pretty linting errors on path names of >80 chars

2 participants