Coverage for src/mafw/devtools/toolchain/tools/pip_audit.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-26 09:13 +0000

1# Copyright 2026 European Union 

2# Author: Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu) 

3# SPDX-License-Identifier: EUPL-1.2 

4""" 

5PipAuditTool — concrete ProjectTool for pip-audit. 

6 

7This module implements the :class:`PipAuditTool` class that manages the 

8``pip-audit`` dependency in the ``dev`` optional-dependencies of 

9``pyproject.toml``. pip-audit is a vulnerability scanner for Python 

10packages and is referenced in a single location, so no cross-file 

11consistency verification is required. 

12 

13Since pip-audit has no ``post_update`` hook or custom logic, its 

14implementation is purely declarative — only the package name and section 

15path differ from the :class:`~mafw.devtools.toolchain.ProjectTool` 

16defaults. 

17""" 

18 

19from __future__ import annotations 

20 

21from mafw.devtools.toolchain import ProjectTool 

22 

23 

24class PipAuditTool(ProjectTool): 

25 """Manage pip-audit's version lower bound in pyproject.toml. 

26 

27 pip-audit is categorized as a *project* tool because its version is 

28 controlled through the ``dev`` optional-dependencies group in 

29 ``pyproject.toml``. There are no additional configuration files to 

30 keep in sync, so :meth:`verify` always returns an empty list (inherited 

31 from :class:`~mafw.devtools.toolchain.ProjectTool`). 

32 

33 All behaviour — bootstrapping, version detection, updating, and 

34 verification — is provided by the :class:`~mafw.devtools.toolchain.ProjectTool` base class. 

35 

36 :param project_root: Path to the project root directory containing 

37 ``pyproject.toml``. Defaults to the current working directory. 

38 :type project_root: Path 

39 """ 

40 

41 @property 

42 def package_name(self) -> str: 

43 """PyPI package name for pip-audit.""" 

44 return 'pip-audit' 

45 

46 @property 

47 def section_path(self) -> str: 

48 """Dot-separated TOML path to the dependency array containing pip-audit.""" 

49 return 'project.optional-dependencies.dev' 

50 

51 @property 

52 def env_name(self) -> str: 

53 """Hatch environment where pip-audit lives.""" 

54 return 'dev'