-
Notifications
You must be signed in to change notification settings - Fork 64
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
mypy errors are not captured and end up directly in the process stdout #19
Comments
One workaround might be to use a mutex in order to prevent concurrent mypy linting. Ultimately, |
This will most likely be resolved in python/mypy#6125. res = subprocess.run(
["python", "-m", "mypy", *args],
stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
report = res.stdout
errors = res.stderr |
@randomstuff amazing tenacity narrowing own the cause of this issue! Let me know if we need an alternative to the pull request solution. |
@elkhadiy started working on a PR on mypy. (@elkhadiy: Tell me if you want some help on the PR.) In the meanwhile, I used the workaround of executing the body of
It's working alright but I don't think it's worth merging this hack as the correct fix (in mypy) should be comparatively simple. |
upgrading mypy to the latest version now solves the issue edit: |
@remorses, mypy's bug is not marked as fixed and at first glance I don't see any change in the latest release in this regard. |
This issue appeared when I activated dmypy in the configuration file: Here is my
When I set |
While debugging an error appearing in Atom IDE-Python plugin, we found that some errors reported by mypy sometimes end up appearing directly in the process stdout (outside on the JSON body) which breaks the protocol:
You can easily check the output of pyls with sysdig:
sysdig -s6000 'proc.cmdline="python -m pyls"' -c stdout
AFAIU, this happens because mypy API currently works by temporarily overriding
sys.stdout
andsys.stderr
which is not thread-safe:The linter tasks are handled in separate threads because of the debouncing feature of python-language-server:
Because stdout overriding is not thread safe,
sys.stout
may not be correctly restored and some errors are actually reported in the real/original/system stdout instead of theStringIO
one.The text was updated successfully, but these errors were encountered: