Skip to content

chore: replace deprecated EnvironmentError alias with OSError (ruff UP024)#154

Open
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-up024-environmenterror-to-oserror
Open

chore: replace deprecated EnvironmentError alias with OSError (ruff UP024)#154
alexzhu0 wants to merge 1 commit intoFlowElement-ai:mainfrom
alexzhu0:chore/ruff-up024-environmenterror-to-oserror

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 2, 2026

Summary

Ruff rule UP024 flags uses of the EnvironmentError alias. Since Python 3.3, EnvironmentError is OSError — same class object, EnvironmentError is OSError returns True. The alias is stylistically redundant.

>>> EnvironmentError is OSError
True

8 raise EnvironmentError(...) sites across 4 files, all in configuration / environment-setup code paths.

 def _require(val: Optional[str], label: str) -> None:
     if not val:
-        raise EnvironmentError(f"Missing required configuration: {label}")
+        raise OSError(f"Missing required configuration: {label}")

Caller compatibility

No except EnvironmentError clauses exist anywhere in the repo (grep -rn "except EnvironmentError" --include='*.py' . — zero hits outside generated code), so caller semantics are unchanged. And even if any did appear, they would continue to catch the raised exception because EnvironmentError is OSError.

Files

File Sites
m_flow/adapters/graph/get_graph_adapter.py 2
m_flow/adapters/vector/create_vector_engine.py 3
m_flow/context_global_variables.py 2
m_flow/shared/files/utils/get_file_content_hash.py 1

4 files, +9 / −9 (one trailing docstring reference updated by hand for consistency).

Verification

$ ruff check . --exclude 'm_flow/baml_client' --exclude 'm_flow-frontend' --select UP024
All checks passed!

$ for f in <each touched file>; do uv run python -c "import ast; ast.parse(open('$f').read())"; done
# clean across all 4 files

$ grep -rn "except EnvironmentError" --include='*.py' . | grep -v baml_client
# (no output — zero call sites catch the aliased form)

No behavior change. Generated code under m_flow/baml_client/ is untouched.

I affirm that all code in every commit of this pull request conforms to the terms of the M-flow Developer Certificate of Origin

…ff UP024)

Since Python 3.3, `EnvironmentError` is an alias that resolves to the
same class object as `OSError` (`EnvironmentError is OSError` returns
True). Ruff's UP024 rule flags the alias as stylistically redundant.

Scope: 8 `raise EnvironmentError(...)` sites across 4 files, all in
configuration / environment-setup code paths. One trailing docstring
reference was updated by hand for consistency.

Verification:
- No `except EnvironmentError` clauses exist anywhere in the repo, so
  caller semantics are unchanged; even if any did, they would continue
  to catch the raised exception because EnvironmentError IS OSError.
- `ruff check . --exclude 'm_flow/baml_client' --select UP024` is now clean
- `ast.parse` on every touched file: clean

No behavior change.
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