Repository navigation
feat(types): simplify the calls that build records, sources and tasks - #821
Merged
masquare merged 6 commits intoNov 20, 2026
Merged
Conversation
masquare
force-pushed
the
feature/connector-api-ergonomics
branch
from
November 19, 2026 17:34
ae756b9 to
8d3fd9f
Compare
karhu
approved these changes
Nov 19, 2026
karhu
left a comment
Contributor
There was a problem hiding this comment.
Like it 💪 one suggestion for the BaseHuggingFaceConnector 's SOURCE_FILES change and one more question here, regarding "!" in the PR. Can't tell what's breaking here. Either remove it or add an explicit "BREAKING CHANGES:" section to the PR description
- add_record, add_task and add_tasks take their argument positionally. - The collection fields of Record, Source and Task accept any iterable and store a tuple. They reject a string, a mapping and a single item. - A task accepts one bare target, such as targets="normal". - Annotation takes key and value positionally, and Source takes name. - A Hugging Face connector sets SOURCE_FILES without an annotation. - Connectors and docs import from the package roots. The connectors and the docs use the new forms.
…ld type - A mapping or bytes value as targets is one bare value, so the task rejects it like the tuple form does. - TupleField names the type of a collection field once. - hello_world uses the list forms everywhere.
Annotation takes only key positionally: Annotation("age", value=64).
A single item that can be iterated, such as a Label, passes the string and mapping checks. With item_type, as_tuple rejects it.
…em type A pydantic model can be iterated, so a single Label passed where a list is expected went through. as_tuple now rejects every pydantic model, so each collection field gets this check and the item_type argument goes.
A Hugging Face connector passes hf_repo, source_revision and source_files as class keywords. The base checks them when the class is defined and stores SOURCE_FILES read-only. A subclass without keywords keeps the values of its parent. The ruff ignore for mutable class defaults in connector modules goes away.
masquare
force-pushed
the
feature/connector-api-ergonomics
branch
from
November 20, 2026 07:25
abf02ae to
c1ef22b
Compare
masquare
changed the base branch from
main
to
feature/hf-source-from-connector
November 20, 2026 07:25
Contributor
Author
|
thx for the suggestion, implemented in new commit |
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.
Shorten the calls that a connector writes to build records, sources and tasks. The types check the same things as before. This builds on #786 below it, and the PRs above use the short forms.
What changes
add_record,add_taskandadd_taskstake their argument positionally:dataset.add_record(record).Record,Source,Signaland the tasks accept any iterable and store a tuple, so a connector passes a list:Record(sources=[...]),inputs=[...]. They reject a string, a mapping and a pydantic model such as a singleLabel, with a clear error. The type of such a field is written asTupleField[X].targets="normal"is the same astargets=("normal",). A mapping or bytes value is rejected.Annotationtakeskeypositionally, andSourcetakesname:Annotation("age", value=64),Source("IMU", signals=[...]). The annotation value is keyword-only.class TSQAConnector(BaseHuggingFaceConnector, hf_repo=..., source_revision=..., source_files={...}). The base checks them when the class is defined and storesSOURCE_FILESread-only. No ruff rule is relaxed.The keyword forms still work, so the tests keep them. The connectors, the docs and the connector-authoring skill use the new forms.
No call that worked before needs a change, except an
Annotationvalue given by position: writeAnnotation("age", value=64).Before and after
Where the logic is
types/_fields.py:as_tuple, the shared converter of the collection fields.types/tasks.py: the bare target.types/annotations.py,dataset/source.py: the positional fields.The rest is connectors, docs and tests.
Checks
make checkandmake test-connectorspass.