feat: scanii-python v1.0.0 — full rewrite#1
Merged
Merged
Conversation
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>
rferreira
commented
May 5, 2026
| key: str | None = None, | ||
| secret: str | None = None, | ||
| token: str | None = None, | ||
| endpoint: str = "https://api.scanii.com", |
Collaborator
Author
There was a problem hiding this comment.
don't default, make sure the end user explicit sets the endpoint
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scanii-pythonas a proper SDK (replaces vestigialscanii.pyskeleton)urllib.request,dataclasses,warnings)process(content, filename)+process_file(path)convenience; same shape forprocess_async/process_async_fileretrieve_trace(id)andprocess_from_url(location)ScaniiProcessingResult.errorships deprecated (emitsDeprecationWarningon construction when non-None)py.typedPEP 561 marker;mypy --strictcleanscanii/setup-cli-action@v1; matrix: Python 3.13 + 3.14 × ubuntu/macos/windowsPyPI note
PyPI name override is pending (pypi/support#10444).
release.ymlis wired but does NOT fire until Rafael publishes a GitHub Release, which is gated on PyPI clearing. Until then, install from source:Test plan
mypy src— no errorsruff check— no errorspython -m build— sdist + wheel producedpytest.warns(DeprecationWarning)asserts onScaniiProcessingResult(error="...")retrieve_trace(known + unknown id),process_from_url(EICAR via URL)process(BytesIO(...))andprocess_file(path)return same findings🤖 Generated with Claude Code