mypy failing with invalid filenames
See original GitHub issueEnvironment 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 (View
→Output
, 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:
- Created 4 years ago
- Reactions:1
- Comments:14 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 likemypy 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).
@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 preventsmypy
from running successfully. And, indeed, the output window didn’t showmypy
’s error message for some reason.FYI also, you can just change the
mypy
path to/bin/echo
(or other paths toecho
, depending on your operating system) without creating a new script or log file. In the output window, you can see the invoking arguments.