Skip to content

Pick correct file if two files with the same name but with different extensions exist #2722

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 8 commits into from
May 4, 2025

Conversation

Chasarr
Copy link
Contributor

@Chasarr Chasarr commented Apr 12, 2025

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Description

To replicate the error that this PR fixes, you need to create two files:

test.py    # Contains Pylint errors
test.py2   # Does not contain Pylint errors

and then I run pylint test.py2 it reports Pylint errors from test.py. (the wrong file)

I believe this was due to a typo/logical error. Before this PR, I don't think the prefer_stubs argument even did anything.

Closes pylint-dev/pylint#3631

@Chasarr
Copy link
Contributor Author

Chasarr commented Apr 12, 2025

Hmm, the CI isn't too happy. Investigating...

@Chasarr Chasarr changed the title Use correct file extension Pick correct file file if two files with the same name but with different extensions exist Apr 12, 2025
@Chasarr Chasarr changed the title Pick correct file file if two files with the same name but with different extensions exist Pick correct file if two files with the same name but with different extensions exist Apr 12, 2025
@Chasarr
Copy link
Contributor Author

Chasarr commented Apr 12, 2025

All tests pass on my machine now, so it should work

Copy link

codecov bot commented Apr 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.21%. Comparing base (ce81c29) to head (e278288).
Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2722   +/-   ##
=======================================
  Coverage   93.21%   93.21%           
=======================================
  Files          93       93           
  Lines       11071    11072    +1     
=======================================
+ Hits        10320    10321    +1     
  Misses        751      751           
Flag Coverage Δ
linux 93.08% <100.00%> (+<0.01%) ⬆️
pypy 93.21% <100.00%> (+<0.01%) ⬆️
windows 93.19% <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.51% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Chasarr
Copy link
Contributor Author

Chasarr commented Apr 15, 2025

I don't think automatic issue closing works between repos, so someone with the correct permissions needs to close it manually.

Copy link
Member

@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 for the fix @Chasarr, do you mind adding some automated tests please ?

@Chasarr
Copy link
Contributor Author

Chasarr commented Apr 18, 2025

Done :)

Copy link
Member

@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 for the automated tests, it looks great. Do you mind adding a changelog entry too ? You probably need to specify that the issue you're closing come from pylint, like this:

Closes pylint-dev/pylint#8589

And if you want to have an aliase for the contributors list you can do it in https://github.com/pylint-dev/astroid/blob/main/script/.contributors_aliases.json#L4

@Chasarr
Copy link
Contributor Author

Chasarr commented Apr 19, 2025

Done! Thanks for the guidance!

@DanielNoord
Copy link
Collaborator

@Pierre-Sassoulas Are you able to review this? Before it goes stale 😄

@Pierre-Sassoulas Pierre-Sassoulas merged commit f52268d into pylint-dev:main May 4, 2025
20 checks passed
Copy link
Contributor

github-actions bot commented May 4, 2025

The backport to maintenance/3.3.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/3.3.x maintenance/3.3.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/3.3.x
# Create a new branch
git switch --create backport-2722-to-maintenance/3.3.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 f52268d03c0d19d869d830444f500c154d8a74e5
# Push it to GitHub
git push --set-upstream origin backport-2722-to-maintenance/3.3.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/3.3.x

Then, create a pull request where the base branch is maintenance/3.3.x and the compare/head branch is backport-2722-to-maintenance/3.3.x.

@Pierre-Sassoulas
Copy link
Member

Sorry for the delay, thank you for the PR, congrats on becoming a contributor :)

@Chasarr
Copy link
Contributor Author

Chasarr commented May 4, 2025

Thank you, this is the first piece of code to a big open source project I have contributed to! Feels good!

@Chasarr
Copy link
Contributor Author

Chasarr commented May 4, 2025

Should I do anything to backport the commit to 3.3.X? Or do you do that?

@Pierre-Sassoulas
Copy link
Member

Don't worry I'm going to do it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Results from wrong file when files have the same name but different extensions
3 participants