Fix type errors flagged by ty 0.0.43#3952
Merged
Merged
Conversation
ty 0.0.43 narrows the negative branch of callable() on a Callable | T union to object, breaking the constant/dynamic config definitions; wrap the resolved value in the existing cast. It also infers the load type variable as Never from factory_na's NoReturn return, collapsing type[Never] | UnionType to UnionType; make factory_na generic so the type variable binds from of_type instead.
GitHub is redirecting windows-2025 to windows-2025-vs2026 by 2026-06-15; use the explicit label to drop the redirect notice.
Replace the blanket call-top-callable suppression with a precise cast to the factory's call signature, so ty type-checks the lazy invocation instead of ignoring it; the non-callable branch returns the value directly.
Resolve the type errors directly instead of suppressing them: - _overlapped stub: declare WriteFile so the Windows pipe write checks - req/file.py: annotate the order lookup as dict[type, int] - pyproject.py: cast the package definition to ConfigConstantDefinition (it is always registered via add_constant) - env_select.py: type the mutually-exclusive group as _ActionsContainer and declare completer on _CliEnvAction The remaining ignores are upstream ty bugs (linked issues), intentional error-path tests, or genuine runtime monkeypatching.
to_list/to_set/to_dict and the argparse get_type helper built parametrized generics with subscript syntax (list[of_type]), which ty reads as a type expression and rejects. Construct them with types.GenericAlias instead - an identical runtime object built as a plain value - dropping the invalid-type-form suppressions.
Split the matrix os entry into a versioned runner image and a bare display name (ubuntu/windows/macos), so required-check contexts no longer churn when the runner image is bumped. The repository ruleset's required status checks were updated to the new names. Runs on windows-2025-vs2026 while keeping the 'on windows' check label.
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.
The scheduled
type/type-minchecks broke oncetybumped to 0.0.43 (we pinty>=0.0.19, so CI pulls the latest). This fixes the failures, removes the Windows-runner deprecation notice without churning required-check names, and cleans up every# ty: ignorethat has a real fix.1. ty 0.0.43 failures
Three new diagnostics from stricter type-variable handling:
src/tox/config/of_type.py—tynow narrows the negative branch ofcallable()on aCallable[[], T] | Tunion toobject. Instead of the old blanket# ty: ignore[call-top-callable]+cast("T", ...), each branch now casts the value to its precise factory signature before invoking it, so the call is type-checked against a known signature.tests/config/loader/test_toml_loader.py—factory_nareturnedNoReturn, sotyinferredLoader.load's type variable asNever, collapsingtype[Never] | UnionTypetoUnionType. Madefactory_nageneric over the sameVso the variable binds fromof_type.2. Windows runner notice + version-less check names
GitHub is redirecting
windows-2025towindows-2025-vs2026by 2026-06-15. The job names embed${{ matrix.os }}, and those strings are the repository ruleset's required-check contexts — so naively renaming the runner would have permanently blocked merges.Instead the matrix
osentry is split into a versioned runnerimageand a bare displayname:Jobs now run on the new image but report stable, version-less check names (
test 3.14 on windows,tox env type on ubuntu, …) that won't churn on future image bumps. The repository ruleset's required status checks were updated to the new names accordingly. Applied tocheck.yamlandweekly.yaml; the release/admin workflows are single ubuntu jobs with no OS in their names and were left unchanged.3.
# ty: ignorecleanup — 8 removed via real type fixesexecute/local_sub_processov.WriteFileunresolvedWriteFileintypestubs/_overlapped.pyipip/req/file.pyinvalid-argument-typedict[type, int]virtual_env/package/pyproject.py.valueunresolvedcasttoConfigConstantDefinition[str](always registered viaadd_constant)session/env_select.py×2invalid-assignment+completerunresolved_ActionsContainer; declaredcompleteron_CliEnvActionconfig/loader/toml/__init__.py×3list[of_type]/dict[...]invalid-type-formtypes.GenericAlias(identical runtime object, plain value expression)config/cli/parser.py×2list[action.type]invalid-type-formGenericAliasconstructionLeft in place (no clean fix)
add_configno-matching-overload×7 (wrong inference of function literals off subclass-of types astral-sh/ty#2428 — fires only whendefault's callable form andpost_processare both present, even with fully-typed args; collapsing the overloads breaks inference differently), plus tox4: (regression) unable to run interactive commands #2374, In parallel mode, tox marks skipped interpreters as succeded. #1495, Support - prefix for commands exit code ignore #2586.test_sets.pypasses deliberately-wrong arguments to assert the raised error.Thread.start, wrapping argparse instance methods, attaching metadata attrs to baseargparse.Action, and a dynamicLiteral[tuple(...)].Verification
tox r -e type(ty 0.0.43) clean; ruff clean; targeted suites (config loader/CLI, env_select, req file, package pyproject, sets) all pass.🤖 Generated with Claude Code