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

fix: Use pathlib.Path on the entire message.location.path #580

Merged
merged 10 commits into from
Feb 15, 2023

Conversation

christokur
Copy link
Contributor

@christokur christokur commented Jan 16, 2023

Fix the support for # noqa

Description

The postfilter.filter_messages does not recognize the paths from lint messages as matches for ignored paths and messages because it only matches part of the path and uses the str representation to compare against sets that use pathlib.Path keys.

Related Issue

#557

Motivation and Context

# noqa support is broken and users lost the ability to suppress messages since 1.8.0

How Has This Been Tested?

Use project tests.
Tested against local repo's where the bug is observed using prospector <= 1.8.4 and # noqa works as expected after the patch.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My change requires a change to the dependencies
  • I have updated the dependencies accordingly
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@christokur christokur marked this pull request as ready for review January 16, 2023 23:30
Copy link
Collaborator

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Thank you ! Would you mind adding a regression tests too, please ?

@christokur
Copy link
Contributor Author

Thank you ! Would you mind adding a regression tests too, please ?

Done. To be fair these tests should have been written when the pathlib refactoring happened.


def test_filter_messages_negative(self):
workdir = Path(__file__).parent / "testdata/test_filter_messages_negative"
with patch("setoptconf.source.commandline.sys.argv", ["prospector"]):
Copy link
Member

Choose a reason for hiding this comment

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

Checkout the tests/utils.py module, patch_execution and patch_cli might do what you need here and might as well reuse it

Copy link
Collaborator

Choose a reason for hiding this comment

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

@christokur I'm not sure you took carlio's comment into account, could you look into it please ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took it into account yes

with patch("setoptconf.source.commandline.sys.argv", ...

and

with patch("sys.argv",  ...

have different semantics which is why I did not use patch_cli

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok refactored things but be aware that pyupgrade also made changes to how typing is used

Copy link
Collaborator

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

LGTM, sorry for the delay !

@Pierre-Sassoulas Pierre-Sassoulas added this to the 1.9.0 milestone Feb 14, 2023
@Pierre-Sassoulas Pierre-Sassoulas merged commit d7e3f9e into landscapeio:master Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants