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

Support pylama for python #2266

Merged
merged 3 commits into from
Feb 8, 2019
Merged

Support pylama for python #2266

merged 3 commits into from
Feb 8, 2019

Conversation

kevinoid
Copy link
Contributor

@kevinoid kevinoid commented Feb 1, 2019

pylama is a popular (>500 stars) plugin-based code audit tool for Python which includes plugins for several other popular tools.

The pylama ALE linter is based on existing python linters and attempts to adopt the same conventions and code as much as possible.

Thanks for considering,
Kevin

@RyanSquared
Copy link
Member

Just to clarify, a "Traceback" message is a possible flaw in the linter itself and not something like a syntax error?

@kevinoid
Copy link
Contributor Author

kevinoid commented Feb 3, 2019

Just to clarify, a "Traceback" message is a possible flaw in the linter itself and not something like a syntax error?

A traceback is printed whenever a linter plugin encounters an unhandled exception. (See pylama/core.py:85-87) The unhandled exception could be due to an unexpected internal error or a syntax error severe enough that the linter plugin can't analyze the file.

For example, the pydocstyle plugin throws ParseError when from __future__ import with_statement occurs after a non-__future__ import, which is what I used to generate the traceback test case.

Does that answer your question?

@RyanSquared
Copy link
Member

If this is a common case, I think there should be a better way to solve it than hide the message behind :ALEDetail, such as putting only the repr-like format of the error as the message, then mentioning :ALEDetail.

@kevinoid
Copy link
Contributor Author

kevinoid commented Feb 4, 2019

I expect it to be about as frequent as python/flake8 and python/vulture, which both share the same behavior for tracebacks. Perhaps traceback detection and handling should be shared between all of them?

[pylama] is a popular (>500 stars) plugin-based code audit tool for
Python which includes plugins for several popular tools.

The pylama ALE linter is based on existing python linters and attempts
to adopt the same conventions and code where possible.

[pylama]: https://github.com/klen/pylama

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Several linters may output traceback messages.  Consolidate the parsing
of the traceback into an ale#python#HandleTraceback function which can
be shared between linters and includes the exception message in the ALE
message text instead of a generic message.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@kevinoid
Copy link
Contributor Author

kevinoid commented Feb 5, 2019

I updated the pull request with an additional commit that consolidates the traceback parsing between the Python linters and uses the exception line (with the type and message) as the ALE text. Let me know what you think.

- Handle eradicate (E800) messages which have a colon after the code.
- Test isort messages, which don't have a code.
- Ignore C0103 for module names resulting from the temporary directory
  not complying with the pylint module name restrictions (module-rgx),
  but do not ignore other C0103 messages (bad names from other names).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@w0rp w0rp merged commit a24f0b4 into dense-analysis:master Feb 8, 2019
@w0rp
Copy link
Member

w0rp commented Feb 8, 2019

Cheers! 🍻

@kevinoid
Copy link
Contributor Author

kevinoid commented Feb 8, 2019

Thanks @w0rp! 🥂

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.

None yet

3 participants