Skip to content

[serve] Fix type regression in RAY_SERVE_HAPROXY_CLOSE_SPREAD_TIME_S - #64752

Merged
abrarsheikh merged 1 commit into
ray-project:masterfrom
johntaylor-cell:serve-haproxy-close-spread-typefix
Jul 14, 2026
Merged

abrarsheikh merged 1 commit into
ray-project:masterfrom
johntaylor-cell:serve-haproxy-close-spread-typefix

Conversation

@johntaylor-cell

Copy link
Copy Markdown
Contributor

#63996 added int(os.environ.get("RAY_SERVE_HAPROXY_CLOSE_SPREAD_TIME_S")) guarded by a separate os.environ.get() truthiness check. The two independent lookups mean neither mypy nor pyrefly can narrow the value to non-None, so int(str | None) fails both checkers -- which currently turns the serve type-check lint shard red for every Serve PR (the mypy/pyrefly serve hooks run --all-files).

Read the env var once into a local so the truthiness guard narrows it; runtime behavior is identical (single lookup, same empty-string -> None handling). Restores the serve allowlist to green.

Related to #64643

@johntaylor-cell
johntaylor-cell requested a review from a team as a code owner July 14, 2026 20:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the retrieval of the RAY_SERVE_HAPROXY_CLOSE_SPREAD_TIME_S environment variable to avoid calling os.environ.get twice. The reviewer suggested using the existing get_env_int utility function instead of introducing a temporary module-level variable, which would make the code cleaner and more consistent.

Comment thread python/ray/serve/_private/constants.py Resolved
@johntaylor-cell johntaylor-cell added go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue labels Jul 14, 2026
@johntaylor-cell
johntaylor-cell force-pushed the serve-haproxy-close-spread-typefix branch from 29c75d7 to c24342f Compare July 14, 2026 20:48

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit c24342f. Configure here.

Comment thread python/ray/serve/_private/constants.py Resolved
ray-project#63996 added int(os.environ.get("RAY_SERVE_HAPROXY_CLOSE_SPREAD_TIME_S"))
guarded by a separate os.environ.get() truthiness check. The two
independent lookups mean neither mypy nor pyrefly can narrow the value
to non-None, so int(str | None) fails both checkers -- which currently
turns the serve type-check lint shard red for every Serve PR (the
mypy/pyrefly serve hooks run --all-files).

Use the existing get_env_int helper, matching how the other int env
vars in this file are read. A non-parsable or empty value now fails at
import, which is the intended behavior. Restores the serve type-check
allowlist to green.

Related to ray-project#64643.

Signed-off-by: john.taylor <[email protected]>
@johntaylor-cell
johntaylor-cell force-pushed the serve-haproxy-close-spread-typefix branch from 94ecf97 to 0990eec Compare July 14, 2026 21:16
eicherseiji added a commit to eicherseiji/ray that referenced this pull request Jul 14, 2026
…ect#64752

The int(os.environ.get(...)) narrowing for RAY_SERVE_HAPROXY_CLOSE_SPREAD_TIME_S
is handled in ray-project#64752, so leave it out of this PR to avoid a duplicate fix and
a re-merge conflict. The AutoscalingContext / autoscaling_state type fixes from
the previous commit stay. mypy will flag constants.py until ray-project#64752 lands on
master and this branch re-merges.

Signed-off-by: Seiji Eicher <[email protected]>
eicherseiji added a commit to eicherseiji/ray that referenced this pull request Jul 14, 2026
Restores the mypy narrowing so this PR's lint is green. This overlaps with
the upstream fix in ray-project#64752; since this PR lands after it, the duplicate
reconciles in the master re-merge.

Signed-off-by: Seiji Eicher <[email protected]>
@johntaylor-cell johntaylor-cell self-assigned this Jul 14, 2026
@abrarsheikh
abrarsheikh enabled auto-merge (squash) July 14, 2026 21:52
@abrarsheikh
abrarsheikh merged commit ce49e2f into ray-project:master Jul 14, 2026
4 checks passed
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ay-project#64752)

ray-project#63996 added
int(os.environ.get("RAY_SERVE_HAPROXY_CLOSE_SPREAD_TIME_S")) guarded by
a separate os.environ.get() truthiness check. The two independent
lookups mean neither mypy nor pyrefly can narrow the value to non-None,
so int(str | None) fails both checkers -- which currently turns the
serve type-check lint shard red for every Serve PR (the mypy/pyrefly
serve hooks run --all-files).

Read the env var once into a local so the truthiness guard narrows it;
runtime behavior is identical (single lookup, same empty-string -> None
handling). Restores the serve allowlist to green.

Related to ray-project#64643

Signed-off-by: john.taylor <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants