-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Provide even more context to the lint context #13186
Provide even more context to the lint context #13186
Conversation
I was wondering if we can further refactor it to separate the linting from the printing in From the point of view of the language server or other services that want information on linting but do their own printing, just calling What do you think? |
Sounds like a good idea. |
Let's get it into 22.01 then. |
tool_line = 0 | ||
tool_path = None | ||
# determine node to report for general problems with stdio | ||
tool_node = tool_xml.find("./tool") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're allowing tool_xml
to be None
here, so I guess you want to guard this with a if tool_xml is not None:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to move the linter tests for yaml and cwl to a separate PR.
The problem here is that the main lint function should distinguish which linters to call based on the tool language and not the tool type. Thus, all the xml linters are called for the yaml tools.
Also with the suggested change the tool_type is still None
(because the yaml file does not include it).
in preparation to get linter tests running for such tools cwl: - remove a print from SchemaLoader yaml: - define YamlToolSource.parse_tool_type otherwise yaml tools are parsed like xml tools - parse_version: return a string, otherwise 1.0 is treated as float which makes the linter (and probably more) fail
while parsing macros
- add fname to LintMessage - LintContext make lint messages persistent over multiple linter calls before the messages were reset before the call of the next linter which is "impractical" if we want to use the lintmessages eg in planemo - add test for linting a tool + (internal and external) macros to ensure that the fname and line number is correct - add a simple linter test for yaml and json tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you have a look if this is useful
Yeah! this is what I had in mind, I can't wait to try and integrate it in GLS :)
I just added some comments mostly about typing, but they are just minor improvements.
@@ -89,59 +124,67 @@ def __init__(self, level, skip_types=None, object_name=None): | |||
self.skip_types = skip_types or [] | |||
self.level = level | |||
self.object_name = object_name | |||
self.found_errors = False | |||
self.found_warns = False | |||
self.message_list = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.message_list = [] | |
self.message_list: List[LintMessage] = [] |
For this, we will need to import from typing import List
but again it is nicer to be explicit about the type here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added type annotations at most places. Maybe you can recheck?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! That's a lot of type hints 😆
Check mypy
errors, usually, they give a nice hint to fix them.
I would use just None
instead of NoReturn
for methods.
As per the documentation:
NoReturn
is a special type to annotate functions that never return normally. For example, a function that unconditionally raises an exception.
3373a22
to
f3ba64e
Compare
subclassed XMLLintMessage
@mvdbeek Guess I have found a solution .. subclassing: LintMessage |
5c75e70
to
665d83e
Compare
212d77c
to
8f94fbe
Compare
Special LintMessage for XML: - one adding line and file name and - one adding XPath added error and report level class also added doc string
This PR was merged without a "kind/" label, please correct. |
Thanks @mvdbeek |
Thanks for all your work on the linting and parameters in general, this is really cool! |
error introduced here galaxyproject#13186 found this while working on galaxyproject/planemo#1264
Follow up on #12978
/tmp/...
)get_lint_context_for_tool_source
and changedlint_tool_source_with
andlint_xml_with
to return the lint context.Also added a first test for linting yaml and cwl tools (and fixed minor bugs)
How to test the changes?
(Select all options that apply)
License