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

Allow specifying which groups under [project.optional-dependencies] are considered development dependencies #628

Merged
merged 14 commits into from
Mar 23, 2024

Conversation

fpgmaas
Copy link
Owner

@fpgmaas fpgmaas commented Mar 20, 2024

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Description of changes

For projects that use PEP 621 without Poetry or PDM, all dependencies under [project.dependencies] and [project.optional-dependencies] are extracted as regular dependencies. This PR adds the --pep621-dev-dependency-groups argument, so users can specify which groups defined under [project.optional-dependencies] should be treated as development dependencies instead.

For example, consider a project with the following pyproject.toml:

[project]
...
dependencies = [
    "httpx",
]

[project.optional-dependencies]
test = [
    "pytest < 5.0.0",
]
plot = [
    "matplotlib",
]

By default, https, pytest and matplotlib are extracted as regular dependencies. By specifying --pep621-dev-dependency-groups=test,
the dependency pytest will be considered a development dependency instead.

@fpgmaas fpgmaas marked this pull request as draft March 20, 2024 20:42
@fpgmaas fpgmaas linked an issue Mar 20, 2024 that may be closed by this pull request
python/deptry/cli.py Outdated Show resolved Hide resolved
@fpgmaas fpgmaas changed the title pep 621 dev dependencies Allow specifying which groups under [project.optional-dependencies] are considered development dependencies Mar 20, 2024
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Attention: Patch coverage is 91.89189% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 90.7%. Comparing base (3efc505) to head (a394966).

Files Patch % Lines
python/deptry/core.py 81.2% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #628     +/-   ##
=======================================
+ Coverage   90.4%   90.7%   +0.3%     
=======================================
  Files         33      33             
  Lines        970     986     +16     
  Branches     189     198      +9     
=======================================
+ Hits         877     895     +18     
+ Misses        79      74      -5     
- Partials      14      17      +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fpgmaas fpgmaas requested review from adamtheturtle and mkniewallner and removed request for adamtheturtle March 21, 2024 06:19
@fpgmaas fpgmaas marked this pull request as ready for review March 21, 2024 06:23
@fpgmaas fpgmaas mentioned this pull request Mar 21, 2024
python/deptry/cli.py Outdated Show resolved Hide resolved
@adamtheturtle
Copy link

This works for my project, vws-python-mock.

@adamtheturtle
Copy link

Perhaps deptry should warn / error if the given group does not exist.

docs/usage.md Outdated Show resolved Hide resolved
@fpgmaas
Copy link
Owner Author

fpgmaas commented Mar 21, 2024

Perhaps deptry should warn / error if the given group does not exist.

Good suggestion! It will now display a warning if there are any groups listed that are not detected:

Warning: Trying to extract the dependencies from the optional dependency groups ['lint'] as development dependencies, but the following groups were not found: ['lint']

@adamtheturtle
Copy link

I'd be happy with this being released :)

@fpgmaas fpgmaas added this to the 0.15 milestone Mar 21, 2024
@fpgmaas fpgmaas mentioned this pull request Mar 21, 2024
4 tasks
@fpgmaas
Copy link
Owner Author

fpgmaas commented Mar 21, 2024

I'd be happy with this being released :)

We'll aim for a release this weekend! I want to give @mkniewallner some more time to review if he wants, I know he is a bit busy these days :)

docs/usage.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@mkniewallner mkniewallner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since PDM also is able to define PDM 621 optional dependencies, I think we should handle the new parameter for it as well. I made #637 to handle that, let me know if you disagree with that (if not, we still have to fix the logging issues that the PR also fixes).

In any case, having this new option will definitely be helpful!

docs/usage.md Outdated Show resolved Hide resolved
docs/usage.md Outdated Show resolved Hide resolved
mkniewallner and others added 3 commits March 23, 2024 20:07
* refactor: move dependencies logging to `core`
* feat(pdm): handle PEP 621 dev groups
Co-authored-by: Mathieu Kniewallner <[email protected]>
Co-authored-by: Mathieu Kniewallner <[email protected]>
@fpgmaas
Copy link
Owner Author

fpgmaas commented Mar 23, 2024

Since PDM also is able to define PDM 621 optional dependencies, I think we should handle the new parameter for it as well. I made #637 to handle that, let me know if you disagree with that (if not, we still have to fix the logging issues that the PR also fixes).

In any case, having this new option will definitely be helpful!

Thanks, great suggestion and good catch on the issue with logging. I merged your PR and added one small commit on top of it.

@fpgmaas fpgmaas merged commit 4bb683b into main Mar 23, 2024
29 checks passed
@fpgmaas fpgmaas deleted the pep621-dev-deps branch March 23, 2024 19:29
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

Successfully merging this pull request may close these issues.

Increase flexibility regarding development dependencies.
4 participants