Skip to content
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

An --ignores argument? #130

Closed
fredrikaverpil opened this issue Mar 10, 2023 · 4 comments · Fixed by #142
Closed

An --ignores argument? #130

fredrikaverpil opened this issue Mar 10, 2023 · 4 comments · Fixed by #142
Labels
enhancement New feature or request

Comments

@fredrikaverpil
Copy link
Owner

fredrikaverpil commented Mar 10, 2023

It's possible there is a use case for an --ignore-packages argument. The user can ignore certain packages and creosote would simply ignore reporting them as unused. The ignores already exists internally here so all that is needed to enable this is to pass an argument to the CLI and pass it onto that function.

The use case could be e.g. using SQLAlchemy with a database driver. You wouldn't import the database driver in your own source code. Instead you would tell SQLAlchemy to use it via e.g. connection or engine creation string. This would be too tricky to support for Creosote, I think.

To avoid forgetting about the ignores (if e.g. discontinuing the use of said database driver above), Creosote could complain if an ignored package is no longer found in the dependency file (pyproject.toml, requirements.txt, ...), prompting the user to also remove the ignore.

🤔 Would it also be useful to ignore certain files/folders from the source code scan?
Anyhow, this would in that case be a different CLI argument, like --ignore-paths.

I'm just leaving this thought here for now to simmer. Please upvote if you think this would be a good addition to Creosote. 😄

@fredrikaverpil fredrikaverpil changed the title Enable to ignore false positives An --ignores argument Mar 10, 2023
@fredrikaverpil fredrikaverpil added the question Further information is requested label Mar 10, 2023
@fredrikaverpil fredrikaverpil changed the title An --ignores argument An --ignores argument? Mar 10, 2023
@fredrikaverpil fredrikaverpil added enhancement New feature or request and removed question Further information is requested labels Mar 10, 2023
@fredrikaverpil
Copy link
Owner Author

It seems what we need here is an --ignore-packages argument but maybe also a good time to introduce the option to configure via pyproject.toml itself? 🤔

Maybe add add a [tool.creosote] section where all config can be stored...?

@grofte
Copy link

grofte commented Mar 14, 2023

Isn't it more of an --additional-packages? And yes. definitely a good idea to off-load it into a configuration file.

@fredrikaverpil
Copy link
Owner Author

fredrikaverpil commented Mar 14, 2023

@grofte haha, yeah - much better

EDIT: Oh, but, wait. Hmmm. 🤔
I don't think extending makes sense, at least not in terms of how the logic is now. I'm thinking of this as "excluding" or "ignoring" packages from the scan.

@fredrikaverpil
Copy link
Owner Author

fredrikaverpil commented Mar 14, 2023

You can now give this a try:

# Creosote build from "exclude-packages" branch, issue 130
$ pipx install --suffix=@130 --force git+https://github.com/fredrikaverpil/creosote.git@exclude-packages
$ creosote@130 --exclude-packages [PACKAGE ...]
$ pipx uninstall creosote@130

Let me know if you encounter any issues!

⚠️ Please note this is all subject to change. Especially the fact that I've been mixing terminology in the README and here in regards to "dependencies" and "packages".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants