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.

mypy failing with invalid filenames

See original GitHub issue

Environment data

  • VS Code version: 1.30.2
  • Extension version (available under the Extensions sidebar): 2019.1.0
  • OS and version: Mac OS X Mojave
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): pipenv

Expected behaviour

Have a virtualenv set up through pipenv.

I installed the following packages in my virtual env (obtained via pipenv run pip freeze :

astroid==2.2.5
attrs==19.1.0
isort==4.3.17
lazy-object-proxy==1.3.1
mccabe==0.6.1
mypy==0.700
mypy-extensions==0.4.1
pylint==2.3.1
rope==0.14.0
six==1.12.0
typed-ast==1.3.1
wrapt==1.11.1

I have the following settings:

{
    "python.pythonPath": "/Users/alombardo10/.local/share/virtualenvs/feeds-file-retrieval-riYOLLaH/bin/python",
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    "python.linting.mypyEnabled": true
}

Actual behaviour

I am deliberately adding type errors

def ciao(a : int) -> None:
    ()

ciao("aaa")

But nothing is reported under Problems for this project, I have another project with similar setup and it works.

I am running via cmdline mypy via pipenv and it definitely catches those.

My suspicion is that it is not calling mypy at all.

Steps to reproduce:

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - mypy##########
##########Linting Output - pylint##########

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
harpajcommented, May 29, 2019

Happy I could help! Using /bin/echo is a clever way of avoiding the bash script, thanks for that! And using illegal characters in the full path appears to be a good minimum example of reproducing the error. @ericsnowcurrently, does this provide you with enough information to reproduce? So, the title of the issue should rather be something like mypy failures are not shown, since no actual linting output is produced.

On a side note, to avoid such issues in the first and make mypy behave the same when being executed from VS code and externally, it might be a good idea to invoke mypy from the working directory and passing the relative path instead of the full path to it (no idea if that’s possible).

1reaction
yxliang01commented, May 28, 2019

@harpaj Thanks for your idea. Indeed, letting it print the calling arguments and reproduce without the extension is a good and easy thing to do - I was only thinking that the extension didn’t even execute mypy due to empty output. For my case, it was that the full path of the files contains illegal character for being a package name which prevents mypy from running successfully. And, indeed, the output window didn’t show mypy’s error message for some reason.

FYI also, you can just change the mypy path to /bin/echo (or other paths to echo, depending on your operating system) without creating a new script or log file. In the output window, you can see the invoking arguments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The mypy command line - mypy 0.991 documentation
A regular expression that matches file names, directory names and paths which mypy should ignore while recursively discovering files to check.
Read more >
'invalid argument' error opening file (and not reading file)
My issue, rather arbitrary, was I was writing a file using open(filename, "w").write(...) , where filename is an invalid pathname or includes unexpected ......
Read more >
Mypy Documentation - Read the Docs
Mypy is a static type checker for Python. Type checkers help ensure that you're using variables and functions in your code correctly.
Read more >
python/mypy - Gitter
So far I couldn't get it to type check because mypy correctly complains that Argument ... the mypy error shown above (when run...
Read more >
Python 3 Types in the Wild: A Tale of Two Type Systems
fails both with MyPy's valid-type and with PyType's invalid- annotation. The tight connections between these 2 MyPy error codes and 3 PyType ...
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