-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Make error message from parsing more explicit #437
Conversation
… in member definition error message.
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.
Thanks for taking care of this. I triggered continuous integration (CI), and I have some minor suggestions below.
python/podio/podio_config_reader.py
Outdated
self._parse_with_regexps(string, no_desc_matchers_cbs) | ||
raise DefinitionError(f"'{string}' is not a valid member definition. Description (Comment after member definition) is missing. Correct Syntax: <type> <name> // <comment>") #require_description is set to True but member definition is missing description |
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._parse_with_regexps(string, no_desc_matchers_cbs) | |
raise DefinitionError(f"'{string}' is not a valid member definition. Description (Comment after member definition) is missing. Correct Syntax: <type> <name> // <comment>") #require_description is set to True but member definition is missing description | |
# check whether we could parse this if we don't require a description and provide more details in the error if we can | |
self._parse_with_regexps(string, no_desc_matchers_cbs) | |
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing. Correct Syntax: <type> <name> // <comment>") |
I would move the comment to the top of these lines, because people are more likely to find it there.
I didn't do anything. The additions were suggested by you only : ) |
It looks like our format and lint checks are not entirely happy yet: https://github.com/AIDASoft/podio/actions/runs/5415352399/jobs/9843528142?pr=437#step:4:499 The rest looks fine. There is one workflow that is known to fail and which you can ignore in this case ( |
Following errors are generated.
|
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.
You will have to fix the format issues to make that check happy. I have marked most of the occurrences below. If you have flake8
and pre-commit
installed locally you can run pre-commit locally. You can also just do pre-commit run -a flake8
to just run the flake8 checks (which is much quicker than the full suite).
python/podio/podio_config_reader.py
Outdated
(self.full_array_re, self._full_array_conv), | ||
(self.member_re, self._full_member_conv) |
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.
Here flake8
complains about too much indentation. So you will have to unindent these (to the same level they were before)
python/podio/podio_config_reader.py
Outdated
(self.bare_array_re, self._bare_array_conv), | ||
(self.bare_member_re, self._bare_member_conv) | ||
] |
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.
Here similar indentation issues are present.
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.
Thanks for fixing the formatting. I just realized that there are also some pylint
warnings, which should be fixed by the comments below.
python/podio/podio_config_reader.py
Outdated
"""check whether we could parse this if we don't require a description and | ||
provide more details in the error if we can""" |
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.
"""check whether we could parse this if we don't require a description and | |
provide more details in the error if we can""" | |
# check whether we could parse this if we don't require a description and | |
# provide more details in the error if we can |
Otherwise pylint complains about a string statement without effect: log
python/podio/podio_config_reader.py
Outdated
raise DefinitionError(f"""'{string}' is not a valid member definition. Description comment is missing. | ||
Correct Syntax: <type> <name> // <comment>""") |
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.
raise DefinitionError(f"""'{string}' is not a valid member definition. Description comment is missing. | |
Correct Syntax: <type> <name> // <comment>""") | |
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing." | |
" Correct Syntax: <type> <name> // <comment>") |
You can also split strings this way and they will be concatenated. I find this a bit more readable.
Doing the above changes. |
python/podio/podio_config_reader.py
Outdated
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing.\n" | ||
+ "Correct Syntax: <type> <name> // <comment>") |
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.
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing.\n" | |
+ "Correct Syntax: <type> <name> // <comment>") | |
raise DefinitionError(f"'{string}' is not a valid member definition. Description comment is missing." | |
" Correct Syntax: <type> <name> // <comment>") |
You don't need the +
in this case, and I would also not put in a newline (\n
) to the output. Other than that this looks good.
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.
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.
Also, I put a + for concatenation of string.
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.
OK. I like the newline. But the +
is not necessary for string concatenation in this case, because it will be done automatically inside the ()
.
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.
Okay, I'll keep the newline character and remove + .
Just waiting for the last few workflows to finish, but they should be fine. Thanks again for all the work (and the patience in addressing my comments). If I may ask: How did you get into contact with podio? |
It was really fun working on this issue and I got to learn a lot about pre-commit through it.
I am selected as HSF India Trainee (IRIS HEP Fellow) and will be working on interfacing PODIO with Julia backend. |
Ah very nice. We will be hearing more from you then :) |
Yes : ) |
BEGINRELEASENOTES
missing description in member definition
error message. Fixes Misleading Error: Invalid Member Definition #436ENDRELEASENOTES
Solves Issue #436 : Misleading Error: Invalid Member Definition