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

Unintended behavior when using multiple source code files/folders #147

Closed
fredrikaverpil opened this issue Mar 15, 2023 · 5 comments
Closed
Assignees

Comments

@fredrikaverpil
Copy link
Owner

What happened?

As reported by @sanmai-NL in #128 (comment):

Can you please document that consecutive --paths parameters override the previous?

Single --paths: an unused dependency is one that isn't referenced at least once in all the Python source code under the specified paths. Multiple --paths: an unused dependency is one that isn't referenced at least once in each of the subsets of source code under each specified path.

This was actually never my intent. Instead my intent is:

An unused dependency is one that isn't referenced at least once in all the Python source code, defined with the -p/--paths argument.

Reproduction steps

Needs steps to reproduce here.

Relevant log output

-
@fredrikaverpil fredrikaverpil added the bug Something isn't working label Mar 15, 2023
@fredrikaverpil fredrikaverpil self-assigned this Mar 15, 2023
@github-actions
Copy link

This issue has been open for 7 days with no activity. Remove the stale label or add a comment or it will be closed in 3 days.

@github-actions github-actions bot added the Stale label Mar 30, 2023
@fredrikaverpil fredrikaverpil removed Stale bug Something isn't working labels Mar 30, 2023
@github-actions
Copy link

github-actions bot commented Apr 7, 2023

This issue has been open for 7 days with no activity. Remove the stale label or add a comment or it will be closed in 3 days.

@github-actions github-actions bot added the Stale label Apr 7, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2023
@fredrikaverpil
Copy link
Owner Author

@sanmai-NL I just took another look at this.

So, I've created two files:

# 147/file1.py

import distlib
import dotty_dict
import loguru
import pip_requirements_parser
# 147/file2.py

import toml

Then I run creosote from within this repo (which uses this repo's pyproject.toml by default) which means it looks for distlib, dotty-dict, loguru, pip-requirements-parser, toml:

❯ creosote -p 147/file1.py             
Found dependencies in pyproject.toml: distlib, dotty-dict, loguru, pip-requirements-parser, toml
Oh no, bloated venv! 🤢 🪣
Unused dependencies found: toml
❯ creosote -p 147/file1.py 147/file2.py
Found dependencies in pyproject.toml: distlib, dotty-dict, loguru, pip-requirements-parser, toml
No unused dependencies found!

To me this is the desired behavior;

  1. You provide creosote with one (and only one) dependencies file as input. These are the dependencies you wish to make sure you have in use.
  2. Then you provide any number of paths to your source code that should in total make use of all the dependencies you've specified.

I don't think what you wrote is accurate here:

Multiple --paths: an unused dependency is one that isn't referenced at least once in each of the subsets of source code under each specified path.

So I am closing this issue. Let me know if you think this is wrong and we can re-open it.

@fredrikaverpil
Copy link
Owner Author

fredrikaverpil commented Apr 10, 2023

It's possible that there has been some confusion here around the intended use of the --paths argument.

The intended use is --paths path1 path2, not --paths path1 --paths path2. If you specify the latter, your definition of the behavior seems true.

I'm by the way addressing this for creosote v3.0.0 and you can preview this feature by enabling it using --use-feature v3-args. Read more here: https://github.com/fredrikaverpil/creosote#%EF%B8%8F-features

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

No branches or pull requests

1 participant