Skip to content

Fix modutils._get_relative_base_path returns incorrect result when directory name starts with directory name in path_to_check #2756

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

Merged
merged 2 commits into from
Jun 1, 2025

Conversation

pavan-msys
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

This PR fixes a bug in astroid.modutils._get_relative_base_path where the function would incorrectly return a partial subpath if the target path started with the same prefix as path_to_check, but was not actually a subdirectory.

Closes #2608

Copy link

codecov bot commented May 26, 2025

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 93.30%. Comparing base (34fbf2e) to head (d0da3a2).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2756   +/-   ##
=======================================
  Coverage   93.29%   93.30%           
=======================================
  Files          93       93           
  Lines       11085    11090    +5     
=======================================
+ Hits        10342    10347    +5     
  Misses        743      743           
Flag Coverage Ξ”
linux 93.16% <100.00%> (+<0.01%) ⬆️
pypy 93.30% <100.00%> (+<0.01%) ⬆️
windows 93.28% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Ξ”
astroid/modutils.py 89.69% <100.00%> (+0.18%) ⬆️
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@DanielNoord
Copy link
Collaborator

@pavan-msys Do you think it is possible to get full coverage on this diff?

@pavan-msys
Copy link
Contributor Author

Hi @DanielNoord

Thanks for the feedback! I added the missing edge test case after the initial coverage was completed, so the current diff should now have full coverage.

@DanielNoord DanielNoord closed this Jun 1, 2025
@DanielNoord DanielNoord reopened this Jun 1, 2025
Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

My bad, I totally missed the fact I still had to approve the run.

Thanks!

@DanielNoord DanielNoord merged commit ee26847 into pylint-dev:main Jun 1, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

modutils._get_relative_base_path returns incorrect result when directory name starts with directory name in path_to_check
2 participants