Skip to content

fix(embed): satisfy ty on Windows-only subprocess attrs#1263

Open
grimmjoww wants to merge 1 commit intovectorize-io:mainfrom
grimmjoww:fix/ty-embed-windows-only-subprocess-attrs
Open

fix(embed): satisfy ty on Windows-only subprocess attrs#1263
grimmjoww wants to merge 1 commit intovectorize-io:mainfrom
grimmjoww:fix/ty-embed-windows-only-subprocess-attrs

Conversation

@grimmjoww
Copy link
Copy Markdown
Contributor

Summary

verify-generated-files (the `ty-embed` lint job) currently fails on `main` because `hindsight_embed/daemon_embed_manager.py:55` references `subprocess.DETACHED_PROCESS` and `subprocess.CREATE_NEW_PROCESS_GROUP` — both Windows-only constants.

The code is already guarded with `if platform.system() == "Windows":` at line 53, so the attributes are never accessed on Linux/macOS at runtime. But `ty`'s static analysis doesn't track platform-conditional branches, so on the Linux CI runner it flags both as `unresolved-attribute` and the job fails.

Fix

Use `getattr(subprocess, "DETACHED_PROCESS", 0)` to avoid the static-analysis false positive while preserving identical runtime behavior on Windows. Same pattern documented in cpython subprocess docs and widely used in cross-platform Python codebases.

Why a separate PR

Spotted while debugging CI on #1258 (reindex-embeddings). That PR doesn't touch `hindsight_embed/` at all — its failing CI is the same unrelated pre-existing issue. Sending the lint fix as its own focused commit so:

After this lands, #1258's CI should go green on rebase.

Test plan

  • Manual: `ty check hindsight_embed/daemon_embed_manager.py` no longer flags those lines
  • Runtime: Windows daemon spawn behavior unchanged (`DETACHED_PROCESS` and `CREATE_NEW_PROCESS_GROUP` are still passed as the same integer values when present, which they always are on Windows)
  • CI green on this PR

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

`subprocess.DETACHED_PROCESS` and `subprocess.CREATE_NEW_PROCESS_GROUP` are
Windows-only constants. The existing code is already guarded by
`if platform.system() == "Windows":`, but `ty`'s static analysis doesn't
track platform-conditional branches, so it flags both attributes as
`unresolved-attribute` on the Linux CI runner — failing
`verify-generated-files`.

Switching to `getattr(subprocess, "DETACHED_PROCESS", 0)` keeps the same
runtime behavior on Windows (constant is present, returned as-is) and
avoids the static-analysis false positive on Linux/macOS where the
attribute access would never execute anyway.

Same fix pattern documented in cpython subprocess docs and used widely
in cross-platform Python codebases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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

Development

Successfully merging this pull request may close these issues.

1 participant