-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose and handle
--config
argument (#245)
* feat: expose and handle configuration file * test(cli): add tests for config in different path * docs(usage): mention that `config` can be overridden
- Loading branch information
1 parent
efcfc03
commit 01f6b83
Showing
23 changed files
with
203 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import shlex | ||
import shutil | ||
import subprocess | ||
from pathlib import Path | ||
|
||
import pytest | ||
from _pytest.tmpdir import TempPathFactory | ||
|
||
from tests.utils import run_within_dir | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def pep_621_dir_with_pyproject_different_directory(tmp_path_factory: TempPathFactory) -> Path: | ||
tmp_path_proj = tmp_path_factory.getbasetemp() / "project_with_pyproject_different_directory" | ||
shutil.copytree("tests/data/project_with_pyproject_different_directory", str(tmp_path_proj)) | ||
with run_within_dir(tmp_path_proj): | ||
assert subprocess.check_call(shlex.split("pip install ."), cwd="a_sub_directory") == 0 | ||
return tmp_path_proj | ||
|
||
|
||
def test_cli_with_pyproject_different_directory(pep_621_dir_with_pyproject_different_directory: Path) -> None: | ||
with run_within_dir(pep_621_dir_with_pyproject_different_directory): | ||
result = subprocess.run( | ||
shlex.split("deptry --config a_sub_directory/pyproject.toml src"), capture_output=True, text=True | ||
) | ||
assert result.returncode == 1 | ||
assert ( | ||
"The project contains obsolete dependencies:\n\n\tisort\n\tmypy\n\tpytest\n\trequests\n\n" in result.stderr | ||
) | ||
assert "There are dependencies missing from the project's list of dependencies:\n\n\twhite\n\n" in result.stderr |
30 changes: 30 additions & 0 deletions
30
tests/data/project_with_pyproject_different_directory/a_sub_directory/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[project] | ||
# PEP 621 project metadata | ||
# See https://www.python.org/dev/peps/pep-0621/ | ||
name = "foo" | ||
version = "1.2.3" | ||
requires-python = ">=3.7" | ||
dependencies = [ | ||
"toml", | ||
"urllib3>=1.26.12", | ||
"isort>=5.10.1", | ||
"click>=8.1.3", | ||
"requests>=2.28.1", | ||
"pkginfo>=1.8.3", | ||
] | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"black==22.10.0", | ||
"mypy==0.982", | ||
] | ||
test = [ | ||
"pytest==7.2.0", | ||
] | ||
|
||
[build-system] | ||
requires = ["setuptools>=61.0.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.deptry] | ||
ignore_obsolete = ["pkginfo"] |
Empty file.
1 change: 1 addition & 0 deletions
1
tests/data/project_with_pyproject_different_directory/src/project_with_src_directory/bar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from project_with_src_directory.foo import a_local_method |
Oops, something went wrong.