-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add a way to ignore the same files as .gitignore
#344
Comments
Yes, that sounds reasonable. I'd be happy to review a pull request that uses .gitignore to exclude files if |
patterns This change updated vulture to use the exclude patterns from the .gitignore file at the root of the input project in the absence of user-provided inputs as a solution to jendrikseipp#344. Vulture now requires the pathspec library to run.
patterns (jendrikseipp#344) Use .gitignore to exclude files if --exclude is missing from both pyproject.toml and the command line. Vulture now requires the pathspec library to run.
…terns (#344) (#345) * Read exclude patterns from .gitignore in absence of user-provided patterns (#344) Use .gitignore to exclude files if --exclude is missing from both pyproject.toml and the command line. Vulture now requires the pathspec library to run. * Move dependencies to requirements.txt. --------- Co-authored-by: Jendrik Seipp <[email protected]>
Fixed in #345 . |
Wow, that was quick. Thanks for doing this, @whosayn and @jendrikseipp |
After further thought, I decided to remove this feature again. The --exclude flag and .gitignore file have different responsibilities and mixing them will surprise some users and will make documentation and maintenance difficult. Also, I'd like Vulture to have no external dependencies, so adding one just for parsing .gitignore files is not ideal. Finally, the feature raised some questions in my mind: why do we only parse the top-level .gitignore file? Why do we parse the .gitignore file in the current directory and not in the directory passed to Vulture? I should have put the brakes on this feature earlier. Sorry about that! |
@jendrikseipp if you don't mind me pushing a bit and seeing if there's possible middle ground, I think I can see a future where these concerns are handled:
By your previous approval here, I was actually expecting this feature to only be merged for the next major version change, clearly indicating to users that there was a breaking change. It could always be available behind a CLI flag though, and only be opt-in. If users enter both a
I think
IMO this is the default with the other tools out there, and sanely handled in the way you describe. I had a local PR I was intending to push up before #345 merged that handled that, using the same logic as Would you mind if I revived my local branch and gave another stab at this feature, given the above? If so, would you agree with the following?
|
Thanks for the detailed proposal! Before we go further here, can you (or others) provide real-world examples of projects where the new feature would be beneficial? I.e., what are example .gitignore files in the wild where all contained gitignore patterns should also be ignored by Vulture? |
I see three main patterns that are encoded in
I've found that these 5 popular repos have at least 2/3 these folders encoded in the |
Thanks! But doesn't this suggest that it'd be better to ignore these directories by default, i.e., fill However, ignoring these directories assumes that users call Vulture like |
I agree with this statement. It's also the default behaviour for many codebase-focused tools, like
Ultimately your call here @jendrikseipp, and one we can hopefully discuss in an upcoming PR.
I guess this line of discussion boils down to aesthetics. Gitignores also handle more complex patterns like "exclude
Personally, that's not very elegant or user-friendly – I don't think it's fair to assume users know |
When using the tool, I need to manually generate an exclusion list parameter that's essentially recreating what my
.gitignore
is doing.Otherwise I end up running the tool on my virtualenv, egg-info, tox, etc. and the initial user experience is that the tool is too slow even on tiny codebases. It would be much simpler to use a flag that tells
vulture
to just exclude the same files as in the.gitignore
– a common enough resource in most repos.One might even go one step further and make that the default – like more modern shell tools like
ripgrep
andfd
, but that's likely a separate discussion.The text was updated successfully, but these errors were encountered: