Skip to content

refactor(lint): lazy exports import names under TYPE_CHECKING - #2590

Merged
dan-petty merged 2 commits into
mainfrom
refactor/2010-ruff-preview-clean
Oct 29, 2026
Merged

dan-petty merged 2 commits into
mainfrom
refactor/2010-ruff-preview-clean

Conversation

@dan-petty

@dan-petty dan-petty commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

With Ruff preview on, Ruff reported 87 findings in code that the stable rules accept, so #1876 could not turn preview on. This change rewrites that code and changes no setting.

  • ai/review, ai/rag, ai/models, ai/benchmark and tests/support/fakes import their exported names under TYPE_CHECKING, built from each module's own export map. At run time they stay lazy (F822).
  • AbstractToolset and FunctionToolset use PEP 695 type parameters (UP046).
  • format_duration and its test write the micro sign as \u00b5; the output is still 500µs (RUF001).
  • tests/test_fast_dispatch.py loses an unused import (F401).

Closes #2010

Change: openspec/changes/archive/2026-10-29-2010-ruff-preview-clean/

With Ruff preview on, Ruff reported 87 findings in code that the
stable rules accept. #1876 cannot turn preview on until they are gone.

- The lazy-export modules ai/review, ai/rag, ai/models, ai/benchmark
  and tests/support/fakes import their exported names under
  TYPE_CHECKING, built from each module's own export map. At run time
  they stay lazy.
- AbstractToolset and FunctionToolset use PEP 695 type parameters.
- format_duration and its test write the micro sign as an escape. The
  output does not change.
- tests/test_fast_dispatch.py loses an import that nothing uses.

No Ruff, mypy or ceiling setting changes.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence (Ruff 0.16.8; the preview setup of #1876: --preview, lint.explicit-preview-rules = true, PLR1702 at max-nested-blocks = 5):

Rule origin/main 33491ca This branch
F822 82 0
UP046 2 0
RUF001 2 0
F401 1 0
PLR1702 0 0
  • uv run ruff check . (current settings) passes, and ruff format --check passes. pyproject.toml is unchanged.
  • uv run mypy src: no issues in 570 files (strict).
  • Import of each of the 5 packages loads none of its submodules; access by name still loads the attribute.
  • uv run devops ci test <changed files> ran the full suite: 12,514 passed in 5 m 22 s.
  • The issue named 8 modules; on 33491ca only 5 report F822. The F401 site is tests/test_fast_dispatch.py:10 (import devops_cli.core, unused), not tests/test_exceptions.py.

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 01:48
@dan-petty
dan-petty merged commit c96dbfe into main Oct 29, 2026
19 of 20 checks passed
@dan-petty
dan-petty deleted the refactor/2010-ruff-preview-clean branch October 29, 2026 01:48
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.13.0](v0.12.0...v0.13.0)
(2026-10-29)


### Features

* **gh:** devops gh issues close records the close reason and a comment
([#2575](#2575))
([97ed0ea](97ed0ea)),
closes [#1658](#1658)
* **monitoring:** the ai spend dashboard counts gateway traffic from the
gateway's own series, shows failed attempts and names each caller
([#2584](#2584))
([33491ca](33491ca))
* **roadmap:** refine writes each criterion as an OpenSpec requirement
([#2591](#2591))
([d9a869f](d9a869f))
* **sandbox:** sandbox commands take a seccomp profile file
([#2588](#2588))
([46958d4](46958d4))


### Bug Fixes

* **monitoring:** RoadmapServiceGitHubWritesHigh counts a request with
no method label as a write, so it fired on 341 reads
([#2583](#2583))
([6dc3aa7](6dc3aa7)),
closes [#2574](#2574)


### Performance Improvements

* **ci:** the gate writes no coverage XML, and the clean-up keeps the
combined data
([#2582](#2582))
([ae9ebb2](ae9ebb2)),
closes [#1743](#1743)
* **roadmap:** intake's embeddings are cached in a password-protected
Valkey in the cluster
([#2578](#2578))
([bfe8a0c](bfe8a0c))


### Code Refactoring

* **devcontainer:** remove the DEVOPS_CLI_SKIP_TOOL_BOOTSTRAP test
switch from product code
([#2580](#2580))
([7e7272e](7e7272e))
* **lint:** lazy exports import names under TYPE_CHECKING
([#2590](#2590))
([c96dbfe](c96dbfe)),
closes [#2010](#2010)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant