pylint-dev / astroid

A common base representation of python source code for pylint and other projects
https://pylint.readthedocs.io/projects/astroid/en/latest/
GNU Lesser General Public License v2.1
532 stars 276 forks source link

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

Open eugene57 opened 1 month ago

eugene57 commented 1 month ago

Consider following call: astroid.modutils._get_relative_base_path('something', os.path.join(os.getcwd(), 'some')). I would expect this to return None by design. However, this returns 'thing' instead.

This results in issues with running pylint on a project with following directory structure:

some
\- __init__.py
something
\- __init__.py
thing
\- __init__.py

I have observed this in astroid version 3.1.0, but it seems to me that the code in master is still the same.