fix(environment): keep the package importable without unix sockets - #621
Open
mikhail-koviazin wants to merge 2 commits into
Open
fix(environment): keep the package importable without unix sockets#621mikhail-koviazin wants to merge 2 commits into
mikhail-koviazin wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8e7c7af. Configure here.
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.

Why
import hudfails on Windows, before any of the code involved is used:Two things run at module scope on a platform that has neither of them: the
_UnixServersubclass inhud/environment/egress.py, andimport ptyinhud/environment/namespace.py.hud/__init__.pyimportsclients, which importsenvironment, so both run on any import of the package, and every command goes down with them. That includes the ones that never go near a workspace:hud --version,hud set,hud jobs.This is a regression.
hud==0.6.12imports on Windows and 0.6.13 onwards does not._UnixServerarrived in 812ae12, and the unguardedimport ptyin d62acae, which moved namespace hosting out ofworkspace.py, where that same import had been behind a platform guard since 50b2acc.The package otherwise treats Windows as somewhere it runs.
workspace.pyguardsfcntl,ptyandtermios, and has acmd.exesession path;hud/cli/__init__.pyrewraps the console so Rich can print on cp1252; six test modules carryskipif(sys.platform == "win32").hud/environment/tests/test_workspace.pymarks its whole module that way, but the marker never gets to apply: collecting the file importsegress, which raises first.What
Both now sit behind the
sys.platform != "win32"guardworkspace.pyalready uses.This does not make workspaces run on Windows, and nothing about the unix machinery changes.
namespace.pystill opensAF_UNIXsockets, so starting an environment there still fails, at the point of use rather than at import. That is where the rest of the package's unix-only paths already fail.It also lets the tests collect.
test_workspace.pyimports_UnixServerat module scope, which raised before this change and would have kept raising after it, so that module's ownskipifnever applied. The import now sits in the one test that uses it, and the whole suite collects on Windows: 1115 collected, 17 deselected, no collection errors. Onmainpytest fails while loadinghud/conftest.py.Left alone:
hud/integrations/harbor/env.pyimportsgrpandpwdat module scope. Nothing in the package imports that module, so it is off theimport hudpath and out of scope here.Tests
hud/environment/tests/test_platform.pyimports the package in a fresh interpreter that reports itself as Windows and has the unix pieces taken away. Before the fix it fails on each of the two separately:AttributeErrorfor the server, andModuleNotFoundErrorforptyonce the server is guarded.It imports the package once as the real platform first, because the standard library settles its own platform on first import (
asynciopickswindows_events,shutilreaches for_winapi) and will not be told otherwise afterwards. Only the package's own modules are then dropped and imported again as Windows.Validation
uv run pytest -quv run ruff format . --checkanduv run ruff check .uv run --extra dev --extra train --extra modal --extra daytona ty check --error-on-warningimport hudandhud --versionboth work, and both fail onmain.