Skip to content
Open
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
4 changes: 3 additions & 1 deletion abi3audit/_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ def __rich_console__(self, console: Console, options: ConsoleOptions) -> RenderR
yield f"[green]:thumbs_up: {self.so}"


def audit(so: SharedObject, assume_minimum_abi3: PyVersion = PyVersion(3, 2)) -> AuditResult:
def audit(so: SharedObject, assume_minimum_abi3: PyVersion | None = None) -> AuditResult:
# We might fail to retrieve a minimum abi3 baseline if our context
# (the shared object or its containing wheel) isn't actually tagged
# as abi3 compatible.
if assume_minimum_abi3 is None:
assume_minimum_abi3 = PyVersion(3, 2)
baseline = so.abi3_version(assume_lowest=assume_minimum_abi3)
if baseline is None:
raise AuditError("failed to determine ABI version baseline: not abi3 tagged?")
Expand Down
12 changes: 6 additions & 6 deletions abi3audit/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def json(self) -> dict[str, Any]:
# TODO(ww): These inner helpers could definitely be consolidated.
def _one_object(results: list[AuditResult]) -> dict[str, Any]:
# NOTE: Anything else indicates a logic error.
assert len(results) == 1
assert len(results) == 1 # noqa: S101
return {"name": results[0].so.path.name, "result": results[0].json()}

def _one_wheel(results: list[AuditResult]) -> list[dict[str, Any]]:
Expand Down Expand Up @@ -228,12 +228,12 @@ def main() -> None:
logging.root.setLevel("DEBUG")

specs = []
for spec in args.specs:
try:
try:
for spec in args.specs:
specs.extend(make_specs(spec, assume_minimum_abi3=args.assume_minimum_abi3))
except InvalidSpec as e:
console.log(f"[red]:thumbs_down: processing error: {e}")
sys.exit(1)
except InvalidSpec as e:
console.log(f"[red]:thumbs_down: processing error: {e}")
sys.exit(1)

logger.debug(f"parsed arguments: {args}")

Expand Down
10 changes: 6 additions & 4 deletions abi3audit/_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class InvalidSpec(ValueError):
specification into something that can be extracted.
"""

pass


class WheelSpec(str):
"""
Expand All @@ -50,6 +48,8 @@ class WheelSpec(str):
A wheel can contain multiple Python extensions, as shared objects.
"""

__slots__ = ()

def _extractor(self) -> Extractor:
"""
Returns an extractor for this wheel's shared objects.
Expand All @@ -64,6 +64,8 @@ class SharedObjectSpec(str):
A shared object may or may not be a Python extension.
"""

__slots__ = ()

def _extractor(self) -> Extractor:
"""
Returns a "trivial" extractor for this shared object.
Expand All @@ -79,6 +81,8 @@ class PyPISpec(str):
may be tagged as abi3 compatible.
"""

__slots__ = ()

def _extractor(self) -> Extractor:
"""
Returns an extractor for each shared object in each published abi3 wheel.
Expand Down Expand Up @@ -125,8 +129,6 @@ class ExtractorError(ValueError):
from the requested source.
"""

pass


class WheelExtractor:
"""
Expand Down
2 changes: 1 addition & 1 deletion abi3audit/_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, extractor: extract.SharedObjectExtractor):
self._extractor = extractor
self.path = self._extractor.path

def abi3_version(self, assume_lowest: PyVersion) -> PyVersion | None:
def abi3_version(self, assume_lowest: PyVersion | None) -> PyVersion | None:
# If we're dealing with a shared object that was extracted from a wheel,
# we try and suss out the abi3 version from the wheel's own tags.
if self._extractor.parent is not None:
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Source = "https://github.com/pypa/abi3audit"

[project.optional-dependencies]
test = ["pytest", "pytest-cov", "pretend", "coverage[toml]"]
lint = ["bandit", "interrogate", "mypy", "ruff", "types-requests"]
lint = ["interrogate", "mypy", "ruff", "types-requests"]
dev = ["build", "pdoc3", "abi3audit[test,lint]"]

[project.scripts]
Expand Down Expand Up @@ -64,14 +64,16 @@ warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

[tool.bandit]
exclude_dirs = ["./test"]

[tool.coverage.run]
omit = ["abi3audit/_vendor/*"]

[tool.ruff]
line-length = 100
exclude = ["abi3audit/_vendor"]

[tool.ruff.lint]
select = ["E", "F", "I", "W", "UP"]
select = ["E", "F", "I", "W", "S", "B", "A", "C4", "EXE", "FA", "ISC", "ICN", "LOG", "PIE", "PYI", "SLOT", "FLY", "PERF", "PGH", "PL", "FURB", "UP"]
ignore = ["PLR1730", "PLR2004"]

[tool.ruff.lint.per-file-ignores]
"test/**.py" = ["S101", "S113"]
18 changes: 0 additions & 18 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.