Skip to content

feat: scanii-python v1.0.0 — full rewrite#1

Merged
rferreira merged 4 commits into
mainfrom
feat/v1.0.0
May 5, 2026
Merged

feat: scanii-python v1.0.0 — full rewrite#1
rferreira merged 4 commits into
mainfrom
feat/v1.0.0

Conversation

@rferreira

Copy link
Copy Markdown
Collaborator

Summary

  • Full rewrite of scanii-python as a proper SDK (replaces vestigial scanii.py skeleton)
  • Zero runtime dependencies, stdlib only (urllib.request, dataclasses, warnings)
  • Stream-first API per streaming-standardization §3.5: process(content, filename) + process_file(path) convenience; same shape for process_async / process_async_file
  • v2.2 preview surface baked in from day one: retrieve_trace(id) and process_from_url(location)
  • ScaniiProcessingResult.error ships deprecated (emits DeprecationWarning on construction when non-None)
  • Full type hints + py.typed PEP 561 marker; mypy --strict clean
  • Apache 2.0 license (replaces old MIT)
  • CI via scanii/setup-cli-action@v1; matrix: Python 3.13 + 3.14 × ubuntu/macos/windows

PyPI note

PyPI name override is pending (pypi/support#10444). release.yml is wired but does NOT fire until Rafael publishes a GitHub Release, which is gated on PyPI clearing. Until then, install from source:

pip install git+https://github.com/scanii/scanii-python.git@main

Test plan

  • CI green: Python 3.13 + 3.14 × ubuntu/macos/windows (39 unit tests + integration suite via scanii-cli)
  • mypy src — no errors
  • ruff check — no errors
  • python -m build — sdist + wheel produced
  • Deprecation warning test: pytest.warns(DeprecationWarning) asserts on ScaniiProcessingResult(error="...")
  • v2.2 tests hard-assert (no self-skip): retrieve_trace (known + unknown id), process_from_url (EICAR via URL)
  • Streaming parity: process(BytesIO(...)) and process_file(path) return same findings

🤖 Generated with Claude Code

Zero-dependency Python SDK for the Scanii content security API.
Ships with stream-first API (process/process_file), v2.2 preview
surface (retrieve_trace, process_from_url), Apache 2.0 license,
full type hints + py.typed, and CI via setup-cli-action.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread src/scanii/client.py Outdated
key: str | None = None,
secret: str | None = None,
token: str | None = None,
endpoint: str = "https://api.scanii.com",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't default, make sure the end user explicit sets the endpoint

rferreira and others added 3 commits May 5, 2026 11:00
Refactor _multipart.encode to return a streaming _ChainedIO instead of
a buffered bytes blob. Mirrors scanii-ruby's ChainedIO / stream_encode
pattern. The file body is only read when urllib reads from the chained
stream on the wire — _multipart.encode never calls file_obj.read().

Content-Length is computed upfront via fileno/fstat for real files,
getvalue() for BytesIO, and seek/tell for other seekable IOs. IOs
with none of the above (pipes, generators) buffer through
SpooledTemporaryFile(max_size=1 MiB) — small payloads stay in memory,
larger ones spill to disk.

Resolves Uncertainty #3 from the initial v1.0.0 report.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rafael secured the scanii-python name on PyPI directly with OIDC
trusted publisher pre-configured. Distribution name is now scanii-python;
import name (src/scanii/) is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the endpoint: str constructor parameter with a required
target: ScaniiTarget. Six regional constants (US1/EU1/EU2/AP1/AP2/CA1)
match the openapi/src/v22.yaml servers block exactly. AUTO is
intentionally absent — data-residency compliance requires an explicit
regional choice. For local testing: ScaniiTarget("http://localhost:4000").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rferreira
rferreira merged commit 5b23e57 into main May 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant