You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WARN Redundant cast: `int` is the same type as `int` [redundant-cast]
--> core/ops/tencent_trace/utils.py:26:20
|
26 | return cast(int, uuid_obj.int)
| -------------------
|
WARN Redundant cast: `int` is the same type as `int` [redundant-cast]
--> core/ops/tencent_trace/utils.py:55:82
|
55 | trace_id = int(trace_id_str, 16) if len(trace_id_str) == 32 else cast(int, uuid.UUID(trace_id_str).int)
| ----------------------------------
This looks like a good refactoring issue! The casts are indeed redundant.
In Python's uuid module, UUID.int is already typed as int (it returns the UUID as a 128-bit integer). Since typing.cast() is a no-op at runtime and only serves as a hint to static type checkers, wrapping an already-int value in cast(int, ...) provides no benefit.
Both lines can be simplified:
Line 26: return uuid_obj.int
Line 55: uuid.UUID(trace_id_str).int
@Gnomeek's offer to take this on sounds great — it's a clean, low-risk cleanup that improves code clarity.
I’m picking up a small follow-up batch for this issue: remove remaining safe redundant-cast warnings (starting with api/core/ops/tencent_trace/utils.py) and run pyrefly + type checks before opening a PR.
Quick update after verification on current upstream/main: I ran uv run --directory api --dev pyrefly check and searched diagnostics for redundant-cast, but found no remaining redundant-cast warnings to fix in this branch snapshot. This one appears to be effectively resolved by prior cleanup PRs.
@crazywoola The user is continuing work on this by removing remaining safe redundant-cast warnings in api/core/ops/tencent_trace/utils.py and plans to run pyrefly and type checks before submitting a PR. Could you please assist them with this follow-up?
Based on a codebase search, it looks like @majiayu000's finding is correct — the obvious redundant-cast warnings (like the ones in tencent_trace/utils.py) have already been cleaned up by prior PRs, most notably PR #24807 (26+ files) and PR #33056 (which specifically removed the cast(int, uuid_obj.int) calls from the trace utilities).
The remaining 100+ typing.cast usages across the codebase are mostly legitimate — things like type narrowing after JSON deserialization, handling SQLAlchemy's Any return types, and complex control flow where static checkers can't infer the narrowed type [1][2]. The project also has reportUnnecessaryCast enabled in pyrightconfig [3], which should prevent new redundant casts from slipping in.
So this issue looks effectively resolved. If pyrefly reports no redundant-cast warnings on the current main branch, there's nothing left to fix here.
Hi, taking another slice of this issue: commands/test_reset_encrypt_key_pair.py — bring the file under strict Pyrefly checks and remove its entry from tests/unit_tests/pyrefly.toml, following #43840 (same pattern). PR to follow shortly.
Hi, I would like to take the libs/test_workspace_permission.py slice: bring the file under strict Pyrefly checks and remove its entry from tests/unit_tests/pyrefly.toml, following the pattern of #43798 / #43840. PR to follow shortly.
I'd like to take only api/tests/unit_tests/core/logging/test_filters.py as a strict-Pyrefly follow-up, leaving the existing claimed modules untouched. The scope is typed real LogRecord fixtures and callbacks, plus removal of this file's strict-mode exclusion, preserving the logging, OpenTelemetry and Flask authentication regression coverage.
Update: I am releasing this scope for now because the local Linux filesystem failed before I could complete the full validation. No source changes or PR have been submitted for this slice. The unchanged file produces 29 strict diagnostics, but the complete runtime baseline is not available.
Activity
Gnomeek commentedon Aug 28, 2025
I can do this.
asukaminato0721 commentedon Feb 23, 2026
asukaminato0721 commentedon Feb 23, 2026
@dosu what do you think
dosubot commentedon Feb 23, 2026
This looks like a good refactoring issue! The casts are indeed redundant.
In Python's
uuidmodule,UUID.intis already typed asint(it returns the UUID as a 128-bit integer). Sincetyping.cast()is a no-op at runtime and only serves as a hint to static type checkers, wrapping an already-int value incast(int, ...)provides no benefit.Both lines can be simplified:
return uuid_obj.intuuid.UUID(trace_id_str).int@Gnomeek's offer to take this on sounds great — it's a clean, low-risk cleanup that improves code clarity.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
majiayu000 commentedon Mar 31, 2026
I’m picking up a small follow-up batch for this issue: remove remaining safe
redundant-castwarnings (starting withapi/core/ops/tencent_trace/utils.py) and run pyrefly + type checks before opening a PR.majiayu000 commentedon Mar 31, 2026
Quick update after verification on current
upstream/main: I ranuv run --directory api --dev pyrefly checkand searched diagnostics forredundant-cast, but found no remainingredundant-castwarnings to fix in this branch snapshot. This one appears to be effectively resolved by prior cleanup PRs.dosubot commentedon Mar 31, 2026
@crazywoola The user is continuing work on this by removing remaining safe
redundant-castwarnings inapi/core/ops/tencent_trace/utils.pyand plans to run pyrefly and type checks before submitting a PR. Could you please assist them with this follow-up?asukaminato0721 commentedon Apr 1, 2026
@dosu are there any redundant-cast now?
dosubot commentedon Apr 1, 2026
Based on a codebase search, it looks like @majiayu000's finding is correct — the obvious
redundant-castwarnings (like the ones intencent_trace/utils.py) have already been cleaned up by prior PRs, most notably PR #24807 (26+ files) and PR #33056 (which specifically removed thecast(int, uuid_obj.int)calls from the trace utilities).The remaining 100+
typing.castusages across the codebase are mostly legitimate — things like type narrowing after JSON deserialization, handling SQLAlchemy'sAnyreturn types, and complex control flow where static checkers can't infer the narrowed type [1] [2]. The project also hasreportUnnecessaryCastenabled in pyrightconfig [3], which should prevent new redundant casts from slipping in.So this issue looks effectively resolved. If pyrefly reports no
redundant-castwarnings on the currentmainbranch, there's nothing left to fix here.To reply, just mention @dosu.
Docs are dead. Just use Dosu.
14 remaining items
Keviniscool-boy commentedon Oct 11, 2026
Hi, taking another slice of this issue:
commands/test_reset_encrypt_key_pair.py— bring the file under strict Pyrefly checks and remove its entry fromtests/unit_tests/pyrefly.toml, following #43840 (same pattern). PR to follow shortly.CodeAlex52 commentedon Oct 11, 2026
Hi, I would like to take the
libs/test_workspace_permission.pyslice: bring the file under strict Pyrefly checks and remove its entry fromtests/unit_tests/pyrefly.toml, following the pattern of #43798 / #43840. PR to follow shortly.Keviniscool-boy commentedon Oct 11, 2026
Claiming
commands/test_clean_expired_messages.py— PR: #43883 (10 diagnostics fixed: 4 not-callable, 4 unannotated-return, 2 implicit-any-type-argument).KissFeng commentedon Oct 15, 2026
Hi @asukaminato0721, I would like to help with this! I will clean up the redundant casts in
api/core/tools/mcp_tool/tool.py.refactor(api): enable strict typing for app/service test files
refactor(api): enable strict typing for small excluded test files
refactor(api): enable strict typing for converter/telemetry/tools tes…
refactor(api): enable strict typing for extraction/fields test files
refactor(api): enable strict typing for app/service test files
refactor(api): enable strict typing for agent/ops/tools test files
github-actions commentedon Oct 30, 2026
Closed due to inactivity. If you have any questions, you can reopen it.
louisss1016 commentedon Nov 2, 2026
I'd like to take only
api/tests/unit_tests/core/logging/test_filters.pyas a strict-Pyrefly follow-up, leaving the existing claimed modules untouched. The scope is typed real LogRecord fixtures and callbacks, plus removal of this file's strict-mode exclusion, preserving the logging, OpenTelemetry and Flask authentication regression coverage.Update: I am releasing this scope for now because the local Linux filesystem failed before I could complete the full validation. No source changes or PR have been submitted for this slice. The unchanged file produces 29 strict diagnostics, but the complete runtime baseline is not available.