Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Update reporters to (allow) use of
end_line
andend_column
#5372Update reporters to (allow) use of
end_line
andend_column
#5372Changes from 3 commits
f395226
09bd841
837b65f
9792d04
45e7bd0
d980fb8
1ed7e17
35fd523
45e0033
0a6e6d6
3c3f141
b24dd1c
6ea66c6
a1bdf7c
6e91225
e280f8c
da4932d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 think we could also change the default for msg-template in 3.0. Do we want the default to have end line and end column ? This seems like something that is useful in an IDE but not a lot for a text output read by humans.
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.
@cdce8p Argued that we might leave the default output as is because of the potential to break many tools. I think this is a discussion which (if we want to have it anyway) we could leave until we are closer to the release of
3.0
. With this merge everybody that wants to can use this new feature!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.
It look like a breaking change that should wait for #4741. We have a 3.0 alpha branch, might be the time to dust it off ?
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.
Reverted! See #5380
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.
Is a
for
- loop really necessary here? Maybe iterate only overPRINT_AS_EMPTY_STRING
and doThere 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.
Or even better, what about this?
Initialize
end_lineno
andend_col_offset
with an empty string instead""
. You still would be able to differentiate between a null value and a number. I.e.int | Literal[""]
as type.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 don't really like that as then we we're changing the type of
end_lineno
andend_col_offset
while still "internal" to fit a specific type of reporter. For example, for theJSONReporter
it makes no sense to have it be""
. I'm not sure if other developer have written otherReporter
but I think keeping both attributesNone
until a specific reporter starts handling them is the better option here.I'll add your first suggestion!
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.writeln(msg.format(self._template))
has been quite elegant, but there is one drawback. Calling it with an unknown key raises aKeyError
. Ideally we could check a template and replace invalid values with""
beforehand. I'm currently having the issue to implement some kind of version check invscode-python
as callingpylint
with the newmsg-template
would raise this error.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.
Shouldn't that just raise a new warning? Something like
config-parse-error
as introduced in #5365. We could emit it on an except for theKeyError
.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.
That doesn't really solve the issue. At the core of it its backwards incompatibility.
We should be able to use a new template, i.e. with
end_lineno
, in oldpylint
versions and still get a usable result. The way it's now, I need to make sure only to addend_lineno
if we are using the new pylint version.If at some point we add another key, this will only repeat. Every time incompatible with old versions.
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.
Came up with something. A little hacky, but let me know what you think. I added
if not self._checked_template:
because I thought the additionalif
statement would be better than doing the regex statement each line.