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 @@ -42,7 +42,7 @@ repos:
priority: 3
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
- repo: https://github.com/gaborbernat/simplint-pre-commit
rev: "c8719dca99c13381570bc69f8955c9448fc271b7" # frozen: v0.7.1
rev: "5f12b15e1199c42bdeb3e13ea1c8b45952fbd802" # frozen: v0.11.0
hooks:
- id: simplint
priority: 4
Expand Down
2 changes: 1 addition & 1 deletion bench/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _profile(work: Path, out: Path, names: list[str], *, py_spy: bool) -> None:


# a helper of main's because, inlined into main, it pushes main over ruff's C901 complexity limit
def _once(name: str, work: Path, stats_file: Path | None) -> None: # simplint: ignore[SMP505] # see above
def _once(name: str, work: Path, stats_file: Path | None) -> None: # simplint: ignore[single-caller-helper] # see above
# without a stats file for an outside profiler such as py-spy
with tempfile.TemporaryDirectory(dir=work, prefix="scratch-") as scratch:
step = make_step(name, load(work), Path(scratch))
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/auditwheel/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from ._greet import hello


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print(hello())
2 changes: 1 addition & 1 deletion docs/examples/flit-core/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
2 changes: 1 addition & 1 deletion docs/examples/hatchling/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
2 changes: 1 addition & 1 deletion docs/examples/meson-python/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from ._greet import hello


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print(hello())
2 changes: 1 addition & 1 deletion docs/examples/pdm-backend/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
2 changes: 1 addition & 1 deletion docs/examples/poetry-core/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
2 changes: 1 addition & 1 deletion docs/examples/scikit-build-core/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
from ._greet import hello


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print(hello())
2 changes: 1 addition & 1 deletion docs/examples/setuptools/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
2 changes: 1 addition & 1 deletion docs/examples/uv-build/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
2 changes: 1 addition & 1 deletion docs/examples/zipapp/src/greet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from __future__ import annotations


def main() -> None:
def main() -> None: # simplint: ignore[undocumented-public-api] # CLI entry point
print("hello")
6 changes: 3 additions & 3 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from python_sbom.hatch import SbomBuildHook


class SelfSbomHook(BuildHookInterface): # simplint: ignore[SMP409] # hatchling loads it from this script
class SelfSbomHook(BuildHookInterface): # simplint: ignore[unused-definition] # hatchling loads it from this script
def initialize(
self,
version: str,
build_data: dict[str, Any], # simplint: ignore[SMP602] # hatchling's signature
build_data: dict[str, Any], # simplint: ignore[imprecise-annotation] # hatchling's signature
) -> None:
self._hook.initialize(version, build_data)

Expand All @@ -39,7 +39,7 @@ def _hook(self) -> SbomBuildHook:
def finalize(
self,
version: str,
build_data: dict[str, Any], # simplint: ignore[SMP602] # hatchling's signature
build_data: dict[str, Any], # simplint: ignore[imprecise-annotation] # hatchling's signature
artifact_path: str,
) -> None:
self._hook.finalize(version, build_data, artifact_path)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ lint.ignore = [
"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
"unnecessary-regular-expression-compile", # conflicts with simplint inline-regex
]
lint.per-file-ignores."bench/**/*.py" = [
"import-private-name", # Benchmarks time the private entry points the public API wraps
Expand Down Expand Up @@ -327,7 +328,7 @@ matrix.platforms = [ "linux_x86_64" ]
# release-creator 4.4.0 needs a seven-day cutoff exception.
# expires 2026-11-17
packages.release-creator.uploaded-prior-to = 2026-11-02T21:45:00Z
# simplint 0.7.1, the pre-commit hook, needs a seven-day cutoff exception.
# simplint 0.11.0 needs a seven-day cutoff exception.
# expires 2026-11-13
packages.simplint.uploaded-prior-to = 2026-11-06T21:30:00Z
# ty 0.0.100 renamed unresolved-attribute to missing-attribute, needs a seven-day cutoff exception.
Expand Down
11 changes: 7 additions & 4 deletions src/python_sbom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from __future__ import annotations

from ._errors import MissingExtraError, SbomError
from ._model._content import BundledWheelInfo, ContentProvider, Contributions, ProviderContext
from ._model._identity import ProjectIdentity
from ._model._inputs import Settings
from ._model._types import (
from ._model import (
BundledWheelInfo,
Component,
Contact,
ContentProvider,
Contributions,
Dependency,
Evidence,
ExternalReference,
Expand All @@ -18,7 +18,10 @@
License,
LicenseInfo,
OrganizationalEntity,
ProjectIdentity,
Property,
ProviderContext,
Settings,
)
from .version import __version__

Expand Down
2 changes: 1 addition & 1 deletion src/python_sbom/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys

from ._cli._main import main
from ._cli import main

if __name__ == "__main__":
main(sys.argv[1:])
8 changes: 8 additions & 0 deletions src/python_sbom/_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
"""The command line: parsing options and running one command per subcommand."""

from __future__ import annotations

from ._main import main

__all__ = [
"main",
]
4 changes: 2 additions & 2 deletions src/python_sbom/_cli/_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path, PurePosixPath
from typing import Protocol

from python_sbom._generate._archive import archive_sbom
from python_sbom._generate._archive import archive_sbom # simplint: ignore[private-import-path] # avoid root export

from ._parser import BuildOptions

Expand Down Expand Up @@ -36,5 +36,5 @@ def run(options: _Options) -> bool:


__all__ = [
"run", # simplint: ignore[SMP402] # the parser names it for pkgutil.resolve_name
"run", # simplint: ignore[unused-export] # the parser names it for pkgutil.resolve_name
]
4 changes: 2 additions & 2 deletions src/python_sbom/_cli/_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from typing import Protocol

from python_sbom._generate._embed import embed_sbom
from python_sbom._generate._embed import embed_sbom # simplint: ignore[private-import-path] # avoid root export

from ._parser import BuildOptions

Expand All @@ -26,5 +26,5 @@ def run(options: _Options) -> bool:


__all__ = [
"run", # simplint: ignore[SMP402] # the parser names it for pkgutil.resolve_name
"run", # simplint: ignore[unused-export] # the parser names it for pkgutil.resolve_name
]
2 changes: 1 addition & 1 deletion src/python_sbom/_cli/_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""The command line's entry point: parse the arguments and run the chosen subcommand."""
"""Run the command line.""" # simplint: ignore[entrypoint-module-name] # console target

from __future__ import annotations

Expand Down
8 changes: 6 additions & 2 deletions src/python_sbom/_cli/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

from __future__ import annotations

from argparse import ArgumentParser, ArgumentTypeError, _SubParsersAction
from argparse import (
ArgumentParser,
ArgumentTypeError,
_SubParsersAction, # simplint: ignore[private-import-path] # argparse has no public type
)
from pathlib import Path
from typing import Protocol

# the limits module imports nothing, so --help and --version load none of validation
from python_sbom._validate._limits import MAX_COMPONENTS
from python_sbom._validate._limits import MAX_COMPONENTS # simplint: ignore[private-import-path] # avoid root export
from python_sbom.version import __version__


Expand Down
17 changes: 12 additions & 5 deletions src/python_sbom/_cli/_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
from typing import TYPE_CHECKING, Protocol

from python_sbom import SbomError
from python_sbom._formats._json import dumps, is_document, load_json
from python_sbom._formats._spdx import render_spdx
from python_sbom._validate._limits import MAX_COMPONENTS, byte_limit
from python_sbom._formats._json import ( # simplint: ignore[private-import-path] # avoid root export
dumps,
is_document,
load_json,
)
from python_sbom._formats._spdx import render_spdx # simplint: ignore[private-import-path] # avoid root export
from python_sbom._validate._limits import ( # simplint: ignore[private-import-path] # avoid root export
MAX_COMPONENTS,
byte_limit,
)

if TYPE_CHECKING:
from pathlib import Path

from python_sbom._model._types import Document
from python_sbom._model._types import Document # simplint: ignore[private-import-path] # avoid root export


class _Options(Protocol):
Expand Down Expand Up @@ -58,5 +65,5 @@ def _read(source: Path) -> Document:


__all__ = [
"run", # simplint: ignore[SMP402] # the parser names it for pkgutil.resolve_name
"run", # simplint: ignore[unused-export] # the parser names it for pkgutil.resolve_name
]
4 changes: 2 additions & 2 deletions src/python_sbom/_cli/_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
from typing import TYPE_CHECKING, Protocol

from python_sbom._validate._artifact import validate
from python_sbom._validate._artifact import validate # simplint: ignore[private-import-path] # avoid root export

if TYPE_CHECKING:
from pathlib import Path
Expand Down Expand Up @@ -38,5 +38,5 @@ def run(options: _Options) -> bool:


__all__ = [
"run", # simplint: ignore[SMP402] # the parser names it for pkgutil.resolve_name
"run", # simplint: ignore[unused-export] # the parser names it for pkgutil.resolve_name
]
12 changes: 12 additions & 0 deletions src/python_sbom/_collect/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
"""What the edge reads: settings, build facts, the source revision, the project tree, the artifact and the provider."""

from __future__ import annotations

from ._revision import REVISION_FILE, default_revision, revision_record
from ._settings import settings_from_pyproject

__all__ = [
"REVISION_FILE",
"default_revision",
"revision_record",
"settings_from_pyproject",
]
17 changes: 11 additions & 6 deletions src/python_sbom/_collect/_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@
from typing import TYPE_CHECKING, Final

from python_sbom import SbomError
from python_sbom._model._archive import bundled_members
from python_sbom._model._inputs import ArchiveTree, RecordRow
from python_sbom._model._metadata import parse_metadata
from python_sbom._model._names import archive_sbom_file_name
from python_sbom._model._archive import bundled_members # simplint: ignore[private-import-path] # avoid root export
from python_sbom._model._inputs import ( # simplint: ignore[private-import-path] # avoid root export
ArchiveTree,
RecordRow,
)
from python_sbom._model._metadata import parse_metadata # simplint: ignore[private-import-path] # avoid root export
from python_sbom._model._names import ( # simplint: ignore[private-import-path] # avoid root export
archive_sbom_file_name,
)

if TYPE_CHECKING:
from collections.abc import Container

from python_sbom._model._metadata import CoreMetadata
from python_sbom._wheel._reader import ArtifactReader
from python_sbom._model._metadata import CoreMetadata # simplint: ignore[private-import-path] # avoid root export
from python_sbom._wheel._reader import ArtifactReader # simplint: ignore[private-import-path] # avoid root export


def read_archive(artifact: ArtifactReader) -> ArchiveTree:
Expand Down
4 changes: 2 additions & 2 deletions src/python_sbom/_collect/_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from typing import TYPE_CHECKING, Final

from python_sbom import SbomError
from python_sbom._model._content import ContentProvider
from python_sbom._model._content import ContentProvider # simplint: ignore[private-import-path] # avoid root export

if TYPE_CHECKING:
from python_sbom._model._inputs import Settings
from python_sbom._model._inputs import Settings # simplint: ignore[private-import-path] # avoid root export


def resolve_provider(
Expand Down
13 changes: 9 additions & 4 deletions src/python_sbom/_collect/_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
from packaging.utils import canonicalize_name

from python_sbom import SbomError
from python_sbom._model._inputs import BuildFacts, InstalledDistribution, Interpreter, RecordRow
from python_sbom._model._metadata import parse_metadata
from python_sbom._model._record import record_rows
from python_sbom._model._inputs import ( # simplint: ignore[private-import-path] # avoid root export
BuildFacts,
InstalledDistribution,
Interpreter,
RecordRow,
)
from python_sbom._model._metadata import parse_metadata # simplint: ignore[private-import-path] # avoid root export
from python_sbom._model._record import record_rows # simplint: ignore[private-import-path] # avoid root export

if TYPE_CHECKING:
from collections.abc import Container, Sequence
from importlib.metadata import Distribution
from pathlib import Path

from python_sbom._model._metadata import CoreMetadata
from python_sbom._model._metadata import CoreMetadata # simplint: ignore[private-import-path] # avoid root export

from ._revision import RevisionReader

Expand Down
2 changes: 1 addition & 1 deletion src/python_sbom/_collect/_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import TYPE_CHECKING, Final, Protocol

from python_sbom import SbomError
from python_sbom._model._inputs import Revision
from python_sbom._model._inputs import Revision # simplint: ignore[private-import-path] # avoid root export

if TYPE_CHECKING:
from pathlib import Path
Expand Down
6 changes: 4 additions & 2 deletions src/python_sbom/_collect/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
from typing import TYPE_CHECKING, TypeAlias

from python_sbom import SbomError
from python_sbom._model._inputs import Settings
from python_sbom._model._inputs import Settings # simplint: ignore[private-import-path] # avoid root export

if TYPE_CHECKING:
from collections.abc import Mapping
from datetime import date, datetime, time
from pathlib import Path
from typing import TypeIs # new in 3.13; annotations here are never evaluated

from python_sbom._model._types import OrganizationalEntity
from python_sbom._model._types import ( # simplint: ignore[private-import-path] # avoid root export
OrganizationalEntity,
)

#: a value of a TOML table, as :mod:`tomllib` or hatchling hand it over
Toml: TypeAlias = "str | int | float | bool | datetime | date | time | list[Toml] | dict[str, Toml]"
Expand Down
Loading
Loading