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

PyLint Comments Work With Other Linter Comments #2537

Closed
wants to merge 5 commits into from

Conversation

DevynCJohnson
Copy link

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

This is the solution for #2297, #2470, and #2485. The code previously would split the the comments into a list and grab the first item without checking that it is grabbing the PyLint comment.

Type of Changes

Type
🐛 Bug fix

Related Issue

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

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

@DevynCJohnson Thanks for the effort. I don't think though that this PR actually solves anything other than a line-too-long potential issue. I'm not sure how are you reproducing the bugs, as I cannot reproduce them locally using the latest. I think that for now we should remove the separate changes and bring in just the change in format.py using the re.sub approach instead of breaking every comment.

@@ -1260,8 +1260,13 @@ def check_line(line, i):
_msg_id.strip() for _msg_id in back_of_equal.split(",")
}:
return None
line = line.rsplit("#", 1)[0].rstrip()

# Find the Pylint comment among all other special comments on the line
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a better solution would be to use re.sub:

line = OPTION_RGX.sub("", line)

@@ -814,7 +814,13 @@ def process_tokens(self, tokens):
match = utils.OPTION_RGX.search(content)
if match is None:
continue

# Find the Pylint comment among all other special comments on the line
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't make sense, OPTION_RGX should be enough to find the corresponding pragma control. It also assumes that we only have disable, which is not the case.

@@ -81,7 +81,7 @@
# Allow stopping after the first semicolon/hash encountered,
# so that an option can be continued with the reasons
# why it is active or disabled.
OPTION_RGX = re.compile(r"\s*#.*\bpylint:\s*([^;#]+)[;#]{0,1}")
OPTION_RGX = re.compile(r'.*#\s*pylint:\s*([^;#]+)[;#]?.*')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think replacing .* with \s* from after the hash makes sense, but not the rest of the changes.

@@ -7,6 +7,16 @@ What's New in Pylint 2.2?

Release date: TBA

* PyLint comments now officially work with other linter comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure your PR actually fixes all these bugs? From what I'm noticing:

Unless you are testing with a completely different code than the one posted in the aforementioned comment, I don't think your PR "fixes" these issues, as they are already fixed. What instead is fixing is that it correctly supports long lines and additional disables, but that's a separate bug.

@PCManticore
Copy link
Contributor

Closing as this is working as intended right now.

@PCManticore PCManticore closed this Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants