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

Reduce redundant lint calls #505

Merged
merged 2 commits into from
Feb 21, 2019
Merged

Conversation

lgeiger
Copy link
Contributor

@lgeiger lgeiger commented Feb 15, 2019

Currently, whenever a file in the workspace changes all open documents are linted. This causes a lot of unnecessary lint calls.
With this PR pyls ignores changes to files that do not end with .py or .pyi and changes that are already handled by the didChange event.

This issue is very problematic when using pyls-mypy. mypy writes cache files after each lint which results in didChangeWatchedFiles to be triggered, resulting in a infinite lint loop.

Currently, whenever a file in the workspace changes all open documents are linted. This causes a lot of unnecessary lint calls.
With this PR changes to files not ending with `.py` or `.pyi` and changes that are already handled by the `didChange` event are ignored.

This issue is very problematic when using [`pyls-mypy'](https://github.com/tomv564/pyls-mypy/). `mypy` writes cache files after each lint which results in `didChangeWatchedFiles` to be triggered, resulting in a infinite lint loop.
@lgeiger
Copy link
Contributor Author

lgeiger commented Feb 20, 2019

@gatesn Do you have time to review this PR?

def m_workspace__did_change_watched_files(self, **_kwargs):
# Externally changed files may result in changed diagnostics
def m_workspace__did_change_watched_files(self, changes=None, **_kwargs):
changed_py_files = set(d['uri'] for d in changes if d['uri'].endswith(('.py', '.pyi')))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be add .cfg and .ini as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd expect that this is handled by didChangeConfig, but on the other hand the client doesn't know that we're also accepting config files.

I'll look into what config file changes should trigger a lint.

Copy link
Contributor

@gatesn gatesn left a comment

Choose a reason for hiding this comment

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

Could you move the list of file extensions to a static at the top? And thoughts about trying to cover some of the linter config files too?

As for the mypy thing, have you tried out #392 ? Wondering whether to invest more time in it

@lgeiger
Copy link
Contributor Author

lgeiger commented Feb 21, 2019

As for the mypy thing, have you tried out #392 ? Wondering whether to invest more time in it

I had a few weird errors with https://github.com/tomv564/pyls-mypy since it occasionally writes to stdout, but I didn't had a chance to checkout your PR. I'll try it our soon.

@lgeiger
Copy link
Contributor Author

lgeiger commented Feb 21, 2019

Could you move the list of file extensions to a static at the top? And thoughts about trying to cover some of the linter config files too?

Fixed in 4bfd36a

if not changed_py_files:
return
# TODO: We currently don't cache settings therefor we can just lint again.
# Here would be the right point to update the settings after a change to config files.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix this TODO after this PR has been merged.

@gatesn gatesn merged commit 0056d00 into palantir:develop Feb 21, 2019
@lgeiger lgeiger deleted the redundant-lint branch February 21, 2019 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants