Repository navigation
chore(py): bump ty to 0.0.82 - #134
Closed
huangjeff5 wants to merge 3 commits into
Closed
huangjeff5 wants to merge 3 commits into
huangjeff5 wants to merge 3 commits into
Conversation
ty 0.0.17 picked overloads differently depending on keyword-argument order, typing define_prompt(..., prompt=, config=, output_schema=) as Unknown. Fixed upstream in 0.0.33; 0.0.82 has the fewest new diagnostics of the versions tried. ty no longer honors coded `# type: ignore[...]`, so intentional wrong-on-purpose test lines get a targeted `ty: ignore[rule]`. Real issues are fixed: StoppableStream is covariant in its chunk type, a bool-returning stop callback becomes a def, anyio TaskGroup is imported directly, define_interrupt and HTTP header resolution narrow without callable(), and plugin maps get precise types. 15 unused ty ignores are removed. pyright and pyrefly results are unchanged.
Resolves conflict in tool_response_contract_test.py and updates ty 0.0.82 diagnostics for newer main changes: - BidiConnection is now contravariant in StreamInT (via _CloseableSink) - Tool.from_action uses method-local TypeVars (_I, _O, _C) - Removes now-unused ty ignores in _action.py, action_test.py, and ref_config_contract_test.py (the ty < 0.0.33 workaround) - Drops now-redundant ModelResponseChunk cast in prompt_test.py - Adds targeted ty ignores for intentional invalid calls in tests
# Conflicts: # pyproject.toml # uv.lock
Collaborator
Author
|
Closing — we'll jump straight to latest |
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.
Bumps ty from 0.0.17 to 0.0.82 and fixes what the new version reports. pyright and pyrefly results are unchanged.
Why
ty 0.0.17 picks an overload differently depending on keyword-argument order. When two overloads both accept a call and a TypeVar is solved from only one argument, passing arguments in a different order than the parameters gives
Unknown:It's fixed upstream as of 0.0.33 (likely astral-sh/ty#3139). I picked 0.0.82 because it had the fewest diagnostics on main of the versions I tried from 0.0.33 to 0.0.104. Latest (0.0.104) reports 176.
What changed in ty that matters
ty no longer honors
# type: ignore[<code>]with a code. A bare# type: ignoreand# ty: ignore[rule]still work. Most of the 143 new diagnostics were on lines that already carried a coded# type: ignore[...]. Those comments stay, since pyright still reads them, and the line gets a# ty: ignore[<rule>]where the code is wrong on purpose.How each category was handled
143 diagnostics before, 0 after.
Receiptis annotated to test return validation,temprature=to test that it raises, positional args to a keyword-only plugin constructor, writes to a frozen ref, monkeypatched methods. Each line gets a targeted# ty: ignore[<rule>].invalid-return-type31invalid-assignment21too-many-positional-arguments17unknown-argument18unresolved-attribute8missing-argument/invalid-type-form/invalid-attribute-override/unresolved-importStoppableStreamis now covariant in its chunk type. It only hands chunks out, andStreamResponse's chunk type is already covariant, soStreamResponse.stream/__aiter__were a variance error._core/_channel.py: the stop callback was a lambda returningbool | Nonewhere() -> Noneis expected. It's a smalldefnow._ai/_aio.py:anyio.abc.TaskGroupdidn't resolve through the module attribute. It's imported fromanyio.abcnow._ai/_tools.py:define_interruptbuilt its metadata through acallable()check that ty can't narrow. It checksNone/dictfirst now; same behavior for every input the signature allows._ai/_agents/_transports/_http.py: header resolution checksdictbefore calling the provider, for the same narrowing reason._ai/_agents/_runtime.py: a detached turn always has a store. That's now acastinstead of atype: ignore.genkit-google-cloud:_GOOGLE_EXC_STATUSis typeddict[str, StatusName], and the exporter's temporality map is annotateddict[type, AggregationTemporality].genkit-openai: the dict branch of tool-call parsing casts todict[str, Any]once.genkit-anthropic: dropped acastthatinnarrowing already covers.cast/assertnarrowing where the test already checked the type (middleware config, prompt chunks, otel attributes, firestore mutator, log exporter records), a typednextcallback,schema.model_validate({...})instead of kwargs on atype[BaseModel]. Insamples/agents/basic/09_detach.py, theSessionSnapshot[JobState]annotation named the non-generic public class; it's inferred now.ty: ignoreremoved: 15 (fastapi handler, reflection middleware,Actioninput-stream cast, mcp tool_meta, tool-response contract).Ignores added in src, with reasons
_core/_channel.py:asyncio.Queue._queueis a private deque typeshed doesn't declare._core/_error.py×2:http_code/retry_after_ms_from_headerstake any object on purpose;int()raising, or a non-mapping raisingAttributeError, is the check.genkit-mcp: theexceptiongroupbackport is only installed on 3.10.genkit-ollama×2: ollama'schatoverloads typeformatnarrower than the schema dict it accepts. pyright already had the same ignore.genkit-openai:reasoning_contentis read insidetry/except AttributeErroron purpose._ai/_prompt.py:GenerateActionOptions.useis typed for wire refs, but middleware instances pass through. pyright already had the same ignore.Follow-up
The
define_promptty ignore inref_config_contract_test.pyon #46 (ty < 0.0.33 bug ...) can come out once #46 and this PR are both on main.Not changed here
These would change a public type, so they're left for a separate decision:
DetachedTask.poll()/wait()return the genericSessionSnapshot[StateT]from_ai/_agents/_client.py, butgenkit.exp.agent.SessionSnapshotis the non-generic core class. Users can't spell the return type.Prompt.__call__(on_chunk=...)is typedCallable[[object], None], so callerscastto read.text.Breaking changes
None. Dev-dependency bump. Runtime and public signatures are unchanged, apart from
StoppableStreamwidening to covariant.