diff --git a/pyproject.toml b/pyproject.toml index d259ff60092..0b760a2b820 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,7 +103,7 @@ extend-exclude = [ "tests/masonry/builders/fixtures/pep_561_stub_only*/*", "tests/utils/fixtures/setups/*", ] -fix = true +fix = false line-length = 88 src = ["src"] target-version = "py38" @@ -123,6 +123,7 @@ extend-select = [ "TCH", # flake8-type-checking "TID", # flake8-tidy-imports "UP", # pyupgrade + "PTH" ] ignore = [ "B904", # use 'raise ... from err' diff --git a/src/poetry/console/commands/check.py b/src/poetry/console/commands/check.py index 1fe9cc550d7..756075f38e8 100644 --- a/src/poetry/console/commands/check.py +++ b/src/poetry/console/commands/check.py @@ -94,8 +94,8 @@ def _validate_readme(self, readme: str | list[str], poetry_file: Path) -> list[s def _validate_dependencies_source(self, config: dict[str, Any]) -> list[str]: """Check dependencies's source are valid""" - sources = {k["name"] for k in config.get("source", [])} - sources.add("pypi") + sources = {repository.name for repository in self.poetry.pool.all_repositories} + print(sources) dependency_declarations: list[ dict[str, str | dict[str, str] | list[dict[str, str]]] @@ -119,6 +119,8 @@ def _validate_dependencies_source(self, config: dict[str, Any]) -> list[str]: elif isinstance(declaration, dict) and "source" in declaration: all_referenced_sources.add(declaration["source"]) + print(all_referenced_sources) + return [ f'Invalid source "{source}" referenced in dependencies.' for source in sorted(all_referenced_sources - sources) diff --git a/tests/console/commands/test_check.py b/tests/console/commands/test_check.py index 957683619a2..a400b55f94f 100644 --- a/tests/console/commands/test_check.py +++ b/tests/console/commands/test_check.py @@ -71,6 +71,7 @@ def test_check_valid(tester: CommandTester) -> None: def test_check_invalid( mocker: MockerFixture, tester: CommandTester, fixture_dir: FixtureDirGetter ) -> None: + mocker.patch( "poetry.poetry.Poetry.file", return_value=TOMLFile(fixture_dir("invalid_pyproject") / "pyproject.toml"),