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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pavan-msys
Copy link

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

Attention: Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.27%. Comparing base (30128b7) to head (f127d53).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
astroid/modutils.py 85.71% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (85.71%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2756      +/-   ##
==========================================
- Coverage   93.29%   93.27%   -0.03%     
==========================================
  Files          93       93              
  Lines       11085    11090       +5     
==========================================
+ Hits        10342    10344       +2     
- Misses        743      746       +3     
Flag Coverage Ξ”
linux 93.13% <85.71%> (-0.03%) ⬇️
pypy 93.27% <85.71%> (-0.03%) ⬇️
windows 93.25% <85.71%> (-0.03%) ⬇️

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

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

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
1 participant