Repository navigation
refactor(api): enable strict typing for rate limit test fixtures - #44391
Open
ShousenZHANG wants to merge 1 commit into
Open
ShousenZHANG wants to merge 1 commit into
ShousenZHANG wants to merge 1 commit into
Conversation
Annotate the rate limiting conftest, drop the mock_time.increment helper that never moved the patched clock, and remove the file from the unit-test Pyrefly exclusions.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Contributor
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #44391 +/- ##
=======================================
Coverage 88.54% 88.55%
=======================================
Files 5522 5522
Lines 331079 331163 +84
Branches 66207 66214 +7
=======================================
+ Hits 293169 293254 +85
- Misses 32724 32727 +3
+ Partials 5186 5182 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
asukaminato0721
enabled auto-merge
October 20, 2026 07:06
asukaminato0721
approved these changes
Oct 20, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 20, 2026
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.
Summary
Part of #24645, following #44331.
tests/unit_tests/core/app/features/rate_limiting/conftest.pywas excluded from strict Pyrefly checks and produced 34 diagnostics, all missing annotations. With this change it is under strict checking.test_rate_limit.pynext to it stays excluded, because #43201 and #43044 are changing it.While typing it,
mock_time.increment()turned out not to work. It advanced a local counter, but the patchedtime.timekept returning thereturn_valueit was created with (1000.0), so calling it never moved the clock. No test calls it; the tests setmock_time.return_valuedirectly. It is removed.mock_redisis unused onmain, but #43201 uses it, so it stays and is typed. No production code changes.What changed
mock_redis. Its in-memory stores and fake Redis methods are typed. The TTL check usesisinstance(ttl, timedelta)instead ofhasattr(ttl, "total_seconds"), which gives the same result for integer andtimedeltaTTLs.mock_time. It patchestime.timewithreturn_value=1000.0and yields the mock, withoutincrement.Generator[...]for the yielding ones, andCallable[..., Generator[str]]forsample_generator.conftest.pyfrom the unit-test Pyrefly exclusions.Verification
pyrefly check --config=tests/unit_tests/pyrefly.toml --use-ignore-files=false --disable-project-excludes-heuristics=trueonconftest.py(fromapi/, Pyrefly 1.3.2 as pinned inuv.lock): 34 diagnostics before, zero after, with no suppressions.pyrefly check --config=tests/unit_tests/pyrefly.tomlover the whole unit-test project: passed.ruff format --checkandruff check(without the cache), on the files and on the wholeapi/treelint-imports: 68 contracts keptscripts/check_no_new_getattr.py,check_no_new_controller_sqlalchemy.py,check_no_new_session_mock.py,check_no_new_base_model.py,check_no_new_test_doubles.pyandcheck_no_spec_mock.pydev/lint_response_contracts.py --fail-on-mismatchpytest -v tests/unit_tests/core/app/features/rate_limitingon Python 3.13: 28 passed, the same 28 test IDs as before the change. With this branch merged into feat: add workspace max active requests limit #43201's head, its rate limiting tests (31) pass.Screenshots
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods (backend only: ran the underlying ruff, import-linter, guard-script and Pyrefly commands listed above)From Claude Code