Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repos:
priority: 5
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
- repo: https://github.com/gaborbernat/simplint-pre-commit
rev: "f15525433ac9797aa1580f46fdadfe60dd77923c" # frozen: v0.8.0
rev: "073bd9250c7a4d15b71eef71f2c95e4af5c76283" # frozen: v0.10.3
hooks:
- id: simplint
priority: 6
Expand Down
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ lint.ignore = [
"DOC", # no restructuredtext support
"hardcoded-bind-all-interfaces", # Possible binding to all interface
"implicit-namespace-package", # no implicit namespaces here
"incorrect-blank-line-before-class", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
"incorrect-blank-line-before-class", # Conflicts with `blank-line-before-class`
"missing-trailing-comma", # Conflict with formatter
"multi-line-summary-first-line", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
"multi-line-summary-first-line", # Conflicts with `multi-line-summary-second-line`
"single-line-implicit-string-concatenation", # Conflict with formatter
"undocumented-magic-method", # undocumented-public-api (simplint SMP903) covers the public API instead
"undocumented-public-class", # undocumented-public-api (simplint SMP903) covers the public API instead
"undocumented-public-function", # undocumented-public-api (simplint SMP903) covers the public API instead
"undocumented-public-init", # undocumented-public-api (simplint SMP903) covers the public API instead
"undocumented-public-method", # undocumented-public-api (simplint SMP903) covers the public API instead
"undocumented-public-nested-class", # undocumented-public-api (simplint SMP903) covers the public API instead
"undocumented-magic-method", # undocumented-public-api (simplint) covers the public API instead
"undocumented-public-class", # undocumented-public-api (simplint) covers the public API instead
"undocumented-public-function", # undocumented-public-api (simplint) covers the public API instead
"undocumented-public-init", # undocumented-public-api (simplint) covers the public API instead
"undocumented-public-method", # undocumented-public-api (simplint) covers the public API instead
"undocumented-public-nested-class", # undocumented-public-api (simplint) covers the public API instead
]
lint.per-file-ignores."src/pyproject_api/_backend.py" = [
"ANN",
Expand Down Expand Up @@ -230,8 +230,8 @@ uploaded-prior-to = "P7D"
decision-order = "stable"
matrix.python = ">=3.15,<3.16"
matrix.platforms = [ "linux_x86_64" ]
# release-creator 4.4.0 needs a seven-day cutoff exception.
# expires 2026-11-09
# The 2026-11-03 lock still needs release-creator 4.4.0's cutoff exception.
# expires 2026-11-18
packages.release-creator.uploaded-prior-to = 2026-11-02T21:45:00Z
# python-sbom 0.1.2 needs a seven-day cutoff exception.
# expires 2026-11-15
Expand Down
2 changes: 1 addition & 1 deletion src/pyproject_api/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def main(argv: list[str]) -> None:

__all__ = [
"main",
"main_parser", # simplint: ignore[SMP402] # the CLI parser is public API, importable from this module
"main_parser", # simplint: ignore[unused-export] # the CLI parser is public API, importable from this module
]


Expand Down
2 changes: 1 addition & 1 deletion src/pyproject_api/_via_fresh_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _send_msg(self, cmd: str, result_file: Path, msg: str) -> Generator[Subproce
def send_cmd(
self,
cmd: str,
**kwargs: Any, # simplint: ignore[SMP602] # send_cmd is a generic transport for any backend command
**kwargs: Any, # simplint: ignore[imprecise-annotation] # generic backend command transport
) -> tuple[JsonValue, str, str]:
"""
Send a command to the backend.
Expand Down
4 changes: 2 additions & 2 deletions tests/demo_pkg_inline/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def build_editable(

def build_wheel(
wheel_directory: str,
metadata_directory: str | None,
config_settings: dict[str, str] | None, # ruff:ignore[unused-function-argument] # the hook signature is fixed by PEP 517
metadata_directory: str | None = None,
config_settings: dict[str, str] | None = None, # ruff:ignore[unused-function-argument] # the hook signature is fixed by PEP 517
) -> str:
base_name = f"{_NAME}-{_VERSION}-py{sys.version_info[0]}-none-any.whl"
path = Path(wheel_directory) / base_name
Expand Down
8 changes: 3 additions & 5 deletions tests/test_backend.py → tests/pyproject_api/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@

import pytest

from pyproject_api import SubprocessFrontend, _backend
from pyproject_api import SubprocessFrontend
from pyproject_api._backend import BackendProxy, read_line, run

if TYPE_CHECKING:
from pathlib import Path

import pytest_mock

from pyproject_api._frontend import JsonValue


def test_invalid_module(capsys: pytest.CaptureFixture[str]) -> None:
with pytest.raises(ImportError):
Expand Down Expand Up @@ -104,7 +102,7 @@ def test_reuse_process(mocker: pytest_mock.MockerFixture, capsys: pytest.Capture
json.dumps({"cmd": "_exit", "kwargs": {}, "result": results[3]}),
]

def fake_backend(name: str, *args: JsonValue, **kwargs: JsonValue) -> JsonValue: # ruff:ignore[unused-function-argument] # the fake backend accepts any call
def fake_backend(name: str, **_kwargs: str) -> str:
if name == "dummy_command_b":
raise SystemExit(2)

Expand Down Expand Up @@ -167,7 +165,7 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
json.dumps({**request, "result": str(path)}) for request, path in zip(requests, result_files, strict=True)
]
completed = subprocess.run(
[sys.executable, _backend.__file__, "True", "exit_backend"],
[sys.executable, "-m", "pyproject_api._backend", "True", "exit_backend"],
input="".join(f"{message}\n" for message in messages),
capture_output=True,
text=True,
Expand Down
File renamed without changes.
19 changes: 16 additions & 3 deletions tests/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import pytest
from packaging.requirements import Requirement

from pyproject_api import _via_fresh_subprocess
from pyproject_api._frontend import BackendFailed
from pyproject_api._via_fresh_subprocess import SubprocessFrontend
from pyproject_api import (
BackendFailed,
SubprocessFrontend,
_via_fresh_subprocess, # simplint: ignore[private-import-path] # spy checks backend thread cleanup
)

if TYPE_CHECKING:
from collections.abc import Callable
Expand Down Expand Up @@ -828,6 +830,17 @@ def test_backend_build_wheel(tmp_path: Path, demo_pkg_inline: Path) -> None:
assert not result.err


def test_backend_build_wheel_with_only_directory(tmp_path: Path, demo_pkg_inline: Path) -> None:
frontend = SubprocessFrontend(*SubprocessFrontend.create_args_from_folder(demo_pkg_inline)[:-1])
filename, _, err = frontend.send_cmd("build_wheel", wheel_directory=str(tmp_path))

assert (filename, (tmp_path / str(filename)).is_file(), err) == (
"demo_pkg_inline-1.0.0-py3-none-any.whl",
True,
"",
)


def test_backend_build_editable_bad(tmp_path: Path, demo_pkg_inline: Path, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("BUILD_EDITABLE_BAD", "1")
frontend = SubprocessFrontend(*SubprocessFrontend.create_args_from_folder(demo_pkg_inline)[:-1])
Expand Down
6 changes: 2 additions & 4 deletions tests/test_frontend_setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@

import pytest

from pyproject_api._frontend import BackendFailed
from pyproject_api._via_fresh_subprocess import SubprocessFrontend
from pyproject_api import BackendFailed, SubprocessFrontend

if TYPE_CHECKING:
from collections.abc import Generator
from pathlib import Path

from _pytest.tmpdir import TempPathFactory
from pytest_mock import MockerFixture

from importlib.metadata import Distribution, EntryPoint


@pytest.fixture(scope="session")
def frontend_setuptools(tmp_path_factory: TempPathFactory) -> SubprocessFrontend:
def frontend_setuptools(tmp_path_factory: pytest.TempPathFactory) -> SubprocessFrontend:
prj = tmp_path_factory.mktemp("proj")
(prj / "pyproject.toml").write_text(
'[build-system]\nrequires=["setuptools","wheel"]\nbuild-backend = "setuptools.build_meta"',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest

import pyproject_api.__main__
from pyproject_api._frontend import EditableResult, SdistResult, WheelResult
from pyproject_api import EditableResult, SdistResult, WheelResult

if TYPE_CHECKING:
import pytest_mock
Expand Down
Loading