Skip to content

[ty] Lazily initialize PEP 723 script environments with uv - #27544

Draft
MichaReiser wants to merge 10 commits into
micha/pep723-script-tag-queryfrom
micha/pep723-uv-script-environments
Draft

[ty] Lazily initialize PEP 723 script environments with uv#27544
MichaReiser wants to merge 10 commits into
micha/pep723-script-tag-queryfrom
micha/pep723-uv-script-environments

Conversation

@MichaReiser

Copy link
Copy Markdown
Member

Summary

Lazily initialize uv-managed environments for checked PEP 723 scripts while preserving standalone configuration precedence and actionable metadata diagnostics.

Test Plan

Testing: Added real-uv script integration coverage and verified the full ty CLI and project test suites.

@astral-sh-bot

astral-sh-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 96.96%. The percentage of expected errors that received a diagnostic held steady at 92.77%. The number of fully passing files held steady at 105/133.

@MichaReiser MichaReiser added preview Related to preview mode features ty Multi-file analysis & type inference labels Aug 6, 2026
@astral-sh-bot

astral-sh-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
prefect 667.79MB 683.56MB +2.36% (15.77MB)
sphinx 208.33MB 213.35MB +2.41% (5.02MB)
trio 94.64MB 94.65MB +0.00% (2.84kB)
flake8 40.42MB 40.42MB +0.00% (624.00B)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
parsed_module 93.01MB 101.19MB +8.80% (8.18MB)
semantic_index 136.94MB 142.07MB +3.75% (5.13MB)
Definition 25.88MB 27.19MB +5.08% (1.31MB)
ScopeId 2.44MB 2.63MB +8.06% (201.09kB)
script_metadata 121.07kB 0.00B -100.00% (121.07kB) ⬇️
script_tag 0.00B 121.07kB +121.07kB (new)
Expression 10.91MB 11.02MB +1.03% (115.00kB)
infer_definition_types 60.42MB 60.50MB +0.14% (86.02kB)
StaticClassLiteral<'db>::try_mro_ 6.88MB 6.92MB +0.68% (48.06kB)
infer_deferred_types 6.77MB 6.81MB +0.66% (45.91kB)
FunctionType<'db>::signature_ 6.30MB 6.34MB +0.62% (39.73kB)
Specialization 6.52MB 6.56MB +0.48% (32.06kB)
CallableType 11.23MB 11.26MB +0.26% (30.06kB)
ResolverEnvironment 14.55kB 44.05kB +202.66% (29.50kB)
FunctionType 9.63MB 9.65MB +0.27% (26.90kB)
... 128 more

sphinx

Name Old New Diff Outcome
semantic_index 42.18MB 45.54MB +7.96% (3.36MB)
Definition 8.73MB 9.62MB +10.23% (914.38kB)
ScopeId 852.93kB 977.15kB +14.56% (124.22kB)
Expression 3.45MB 3.53MB +2.14% (75.69kB)
infer_definition_types 14.07MB 14.14MB +0.49% (70.80kB)
infer_deferred_types 2.81MB 2.86MB +1.95% (55.94kB)
CallableType 1.96MB 2.00MB +2.06% (41.38kB)
script_metadata 32.85kB 0.00B -100.00% (32.85kB) ⬇️
script_tag 0.00B 32.80kB +32.80kB (new)
FunctionType<'db>::signature_ 2.11MB 2.14MB +1.44% (31.02kB)
StaticClassLiteral<'db>::try_mro_ 2.18MB 2.21MB +1.36% (30.38kB)
parsed_module 42.20MB 42.18MB -0.07% (28.55kB) ⬇️
place_by_id 1.35MB 1.37MB +1.43% (19.73kB)
Specialization 1.89MB 1.90MB +0.92% (17.83kB)
Type<'db>::class_member_with_policy_inner_ 3.33MB 3.35MB +0.50% (17.20kB)
... 123 more

trio

Name Old New Diff Outcome
script_metadata 15.80kB 0.00B -100.00% (15.80kB) ⬇️
script_tag 0.00B 15.80kB +15.80kB (new)
infer_definition_types 4.51MB 4.51MB +0.03% (1.57kB)
check_file_impl 638.85kB 640.11kB +0.20% (1.27kB)
Project 24.12kB 24.13kB +0.03% (8.00B)

flake8

Name Old New Diff Outcome
script_metadata 7.67kB 0.00B -100.00% (7.67kB) ⬇️
script_tag 0.00B 7.67kB +7.67kB (new)
check_file_impl 36.81kB 37.41kB +1.63% (616.00B)
Project 23.31kB 23.31kB +0.03% (8.00B)

@astral-sh-bot

astral-sh-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
unresolved-import 9 28 0
unresolved-attribute 2 0 2
possibly-missing-submodule 2 0 0
invalid-argument-type 0 0 1
Total 13 28 3

Large timing changes:

Project Old Time New Time Change
pybind11 0.08s 0.27s +247%
scikit-build-core 0.10s 0.16s +57%
Raw diff (44 changes)
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- .gitlab/scripts/summarize_failures.py:47:6 error[unresolved-import] Cannot resolve imported module `claude_agent_sdk`
- .gitlab/scripts/summarize_failures.py:48:6 error[unresolved-import] Cannot resolve imported module `claude_agent_sdk`
- .gitlab/scripts/summarize_failures.py:49:6 error[unresolved-import] Cannot resolve imported module `claude_agent_sdk`
- .gitlab/scripts/summarize_failures.py:50:6 error[unresolved-import] Cannot resolve imported module `claude_agent_sdk`
- .gitlab/scripts/summarize_failures.py:51:8 error[unresolved-import] Cannot resolve imported module `httpx`
- ddtrace/appsec/_iast/_taint_tracking/_vendor/pybind11/tools/make_global.py:10:8 error[unresolved-import] Cannot resolve imported module `tomlkit`
- scripts/check_profiling_native_coverage.py:33:6 error[unresolved-import] Cannot resolve imported module `ruamel.yaml`
- scripts/get-target-milestone.py:15:8 error[unresolved-import] Cannot resolve imported module `packaging.version`
- scripts/resolve_previous_version.py:45:6 error[unresolved-import] Cannot resolve imported module `packaging.version`
- scripts/resolve_previous_version.py:46:6 error[unresolved-import] Cannot resolve imported module `packaging.version`
- ddtrace/appsec/_iast/_taint_tracking/_vendor/pybind11/tools/make_changelog.py:11:8 error[unresolved-import] Cannot resolve imported module `ghapi.all`
- ddtrace/appsec/_iast/_taint_tracking/_vendor/pybind11/tools/make_changelog.py:12:6 error[unresolved-import] Cannot resolve imported module `rich`
- ddtrace/appsec/_iast/_taint_tracking/_vendor/pybind11/tools/make_changelog.py:13:6 error[unresolved-import] Cannot resolve imported module `rich.syntax`
+ ddtrace/appsec/_iast/_taint_tracking/_vendor/pybind11/tools/make_changelog.py:34:16 warning[possibly-missing-submodule] Submodule `page` might not have been imported
+ ddtrace/appsec/_iast/_taint_tracking/_vendor/pybind11/tools/make_changelog.py:35:5 error[unresolved-attribute] Object of type `GhApi` has no attribute `issues`
- scripts/check-dependency-ci-coverage.py:51:6 error[unresolved-import] Cannot resolve imported module `packaging.requirements`
- scripts/check-dependency-ci-coverage.py:52:6 error[unresolved-import] Cannot resolve imported module `packaging.specifiers`
- scripts/check-dependency-ci-coverage.py:53:6 error[unresolved-import] Cannot resolve imported module `packaging.version`
- scripts/check-dependency-ci-coverage.py:54:8 error[unresolved-import] Cannot resolve imported module `requests`
- scripts/check-dependency-ci-coverage.py:55:8 error[unresolved-import] Cannot resolve imported module `tomllib`
- scripts/check-dependency-ci-coverage.py:407:10 error[unresolved-import] Cannot resolve imported module `riot`
+ scripts/check-dependency-ci-coverage.py:409:12 error[unresolved-import] Cannot resolve imported module `riotfile`
- scripts/ddtrace_module_graph.py:245:12 error[unresolved-import] Cannot resolve imported module `matplotlib`
- scripts/ddtrace_module_graph.py:248:12 error[unresolved-import] Cannot resolve imported module `matplotlib.pyplot`
- scripts/ddtrace_module_graph.py:249:12 error[unresolved-import] Cannot resolve imported module `networkx`
- scripts/ddtrace_module_graph.py:250:12 error[unresolved-import] Cannot resolve imported module `numpy`
- scripts/gen_gitlab_config.py:827:8 error[unresolved-import] Cannot resolve imported module `ruamel.yaml`
+ scripts/gen_gitlab_config.py:205:12 error[unresolved-import] Cannot resolve imported module `riotfile`
+ scripts/gen_gitlab_config.py:352:14 error[unresolved-import] Cannot resolve imported module `needs_testrun`
+ scripts/gen_gitlab_config.py:353:14 error[unresolved-import] Cannot resolve imported module `needs_testrun`
+ scripts/gen_gitlab_config.py:567:10 error[unresolved-import] Cannot resolve imported module `needs_testrun`
+ scripts/gen_gitlab_config.py:605:10 error[unresolved-import] Cannot resolve imported module `needs_testrun`
+ scripts/gen_gitlab_config.py:813:12 error[unresolved-import] Cannot resolve imported module `needs_testrun`
- scripts/integration_registry/generate_supported_versions.py:20:6 error[unresolved-import] Cannot resolve imported module `packaging.version`
+ scripts/integration_registry/generate_supported_versions.py:28:8 error[unresolved-import] Cannot resolve imported module `riotfile`
- scripts/needs_testrun.py:27:6 error[unresolved-import] Cannot resolve imported module `lxml`
+ scripts/needs_testrun.py:32:6 error[unresolved-import] Cannot resolve imported module `tests.suitespec`
- scripts/run-script-doctests.py:29:46 error[invalid-argument-type] Argument to function `module_from_spec` is incorrect: Expected `ModuleSpec`, found `ModuleSpec | Unknown | None`
+ scripts/run-script-doctests.py:29:46 error[invalid-argument-type] Argument to function `module_from_spec` is incorrect: Expected `ModuleSpec`, found `ModuleSpec | None`
- scripts/run-script-doctests.py:30:5 error[unresolved-attribute] Attribute `exec_module` is not defined on `None` in union `Unknown | None`
+ scripts/run-script-doctests.py:30:5 error[unresolved-attribute] Attribute `exec_module` is not defined on `None` in union `Loader | None`
- scripts/run-script-doctests.py:30:5 error[unresolved-attribute] Attribute `loader` is not defined on `None` in union `ModuleSpec | Unknown | None`
+ scripts/run-script-doctests.py:30:5 error[unresolved-attribute] Attribute `loader` is not defined on `None` in union `ModuleSpec | None`

pybind11 (https://github.com/pybind/pybind11)
- tools/make_global.py:10:8 error[unresolved-import] Cannot resolve imported module `tomlkit`
- tools/make_changelog.py:13:8 error[unresolved-import] Cannot resolve imported module `ghapi.all`
+ tools/make_changelog.py:59:16 warning[possibly-missing-submodule] Submodule `page` might not have been imported
+ tools/make_changelog.py:60:5 error[unresolved-attribute] Object of type `GhApi` has no attribute `issues`

Full report with detailed diff (timing results)

@astral-sh-bot

astral-sh-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@codspeed-hq

codspeed-hq Bot commented Aug 6, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 5.91%

⚡ 1 improved benchmark
✅ 156 untouched benchmarks
🆕 2 new benchmarks
⏩ 36 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ty_micro[mixed_typed_dict_union_copy] 121.7 ms 114.9 ms +5.91%
🆕 Simulation ty_micro[missing_key_typed_dict_union_copy] N/A 92.1 ms N/A
🆕 WallTime simple_script N/A 130.1 ms N/A

Tip

Curious why this is faster? Use the CodSpeed MCP and ask your agent.


Comparing micha/pep723-uv-script-environments (7c801e1) with micha/pep723-script-tag-query (f2c1192)

Open in CodSpeed

Footnotes

  1. 36 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@MichaReiser

Copy link
Copy Markdown
Member Author

The pybind11 slowdown is now confirmed: it contains three PEP 723 scripts, so each check launches three concurrent uv workspace metadata --sync --script subprocesses; CI increased from 58 ms to 198 ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant