-
-
Notifications
You must be signed in to change notification settings - Fork 610
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 pyproject.toml
as default input file format
#1780
Conversation
Co-authored-by: Albert Tugushev <albert@tugushev.ru>
for more information, see https://pre-commit.ci
@berislavlopac I a very happy to see your proposed that. I was planning to do it myself for quite a few weeks but failed to find the time. Now you can be sure I will do my best to get this merged. |
@berislavlopac Apparently there is a reduction in codecoverage reported by codecov, one that seems to be genuine. |
@ssbarnea I'm confused - it looks like codecov is complaining that the lines in the test file were not covered by tests? 🤔 |
@berislavlopac yes, from https://app.codecov.io/gh/jazzband/pip-tools/pull/1780 it's evident that the else-block code branch doesn't get executed, meaning that |
Looking at the diff, it's probably related to the fact that you test against CWD which is a bad idea. Look at how other tests create temporary directory structure for all the cases they cover. |
tests/test_cli_compile.py
Outdated
default_file_names = ("requirements.in", "setup.py", "pyproject.toml", "setup.cfg") | ||
make_module(fname=fname, content=content, base_dir=os.getcwd()) | ||
out = runner.invoke(cli) | ||
if fname in default_file_names: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, the tests should be simple and test one thing only. Once logic is added, they tend to become hard to read/understand as well as easy to be misleading/buggy.
@webknjaz I agree with your points, and will look into the alternative to I'm splitting the test into two separate cases, one for when there is an allowed file and another without it. That said, I would still argue that we don't need to include |
It does require those, but it can still contain the deps list on its own. I don't remember exactly, but I think that pip-tools might be loading it directly. |
Okay, after further thought I am okay with keeping in the explicitly defined default list, especially if it's listed after the other two. 👍 |
Since this test is for the functionality that depends directly on some files being present (or not) in the CWD, I'm not sure what would be the right way to test it, apart from creating those files in the CWD (which the current tests do)? 🤔 |
https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.MonkeyPatch.chdir into an empty https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html? |
@webknjaz Done, at the cost of a couple more fixtures added to the test. 😄 |
Co-authored-by: Albert Tugushev <albert@tugushev.ru>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. A few comments.
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thank you very much for your patience!
pyproject.toml
as default input file format
Added
pyproject.toml
as a default input file name that is searched for whenpip-compile
is invoked without arguments; see #1779 for details.The default file names are searched in the following order, with the first encountered being used to compile:
requirements.in
setup.py
setup.cfg
pyproject.toml
Closes #1779.
Contributor checklist
Maintainer checklist
backwards incompatible
,feature
,enhancement
,deprecation
,bug
,dependency
,docs
orskip-changelog
as they determine changelog listing.