Separate pyproject.toml location from root argument#244
Separate pyproject.toml location from root argument#244mkniewallner merged 4 commits intofpgmaas:mainfrom
pyproject.toml location from root argument#244Conversation
Codecov Report
@@ Coverage Diff @@
## main #244 +/- ##
=======================================
- Coverage 95.7% 95.6% -0.1%
=======================================
Files 32 32
Lines 915 906 -9
Branches 203 200 -3
=======================================
- Hits 876 867 -9
Misses 26 26
Partials 13 13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
Keeping it as a draft for now, since this might be controversial, and I would like to have your opinion on the changes first. |
There was a problem hiding this comment.
I think this is a very welcome change, thanks! It did not cross my mind, but it seems to be what tools like isort and black do as well, so probably also the behaviour users would expect.
As you mentioned, this does mean that we could potentially introduce breaking changes in other projects using deptry. I think it would be good to not create a release after merging this PR, and then - since the project is also approaching reasonable maturity - to create our first major release after merging both this PR and #245.
Do you agree?
Semantic versioning explicitly authorises introducing breaking changes in Personally, for now, I like that we are able to update the API of the CLI or the library's behaviour without having to give too much thoughts about it, even if it is still a good thing to not break possible current usages of it (like this PR + #245 do, by offering alternatives), and of course, communicate about the changes we are making in the changelog. If we want to respect semantic version, going into There are IMO reasons why major libraries like In any case, I agree that it would be best to tag a release once #245 is also merged, but based on everything mentioned above, I would personally bump the version to |
|
Thanks, that makes sense. I was unaware that breaking changes can be introduced in version |
PR Checklist
docsis updatedDescription of changes
deptryallows passing the root directory as a positional argument, which gives some flexibility to projects that use different kind of structures.This is for instance useful for projects that use an
srcdirectory structure, like Poetry or Hatch.Unfortunately, the root directory passed as a command line means that the configuration file will be read from the directory, and not from the directory
deptryis launched from, diverging, in my opinion, to what most other tools in the ecosystem do.This PR is an attempt to fix that by always trying to load
pyproject.tomlfrom the locationdeptryis run from, both for reading[tool.deptry]configuration, or extracting the dependencies if a project uses PEP 621 or Poetry.This means that when running:
deptrywill now search forpyproject.tomlin the location it is run from, whereas currently, doing so will makedeptrylook for apyproject.tomlinsrcdirectory.The downside is that this could break some projects that did explicitly want to find
pyproject.tomlin a root directory other than., but I have a second PR (#245) building upon this one that exposes the--configargument, making it possible to explicitly pass the location ofpyproject.toml, giving both flexibility for passing a different root directory and allowing to continue supporting this use case, if it exists.