ruff UP021
labelled unknown
Analysis Nemotron 3 Super
Flags use of deprecated 'universal_newlines' kwarg in subprocess.run calls.
Fix: Replaces the 'universal_newlines' keyword argument with 'text' while preserving its value.
12 hazards
- Rewriting universal_newlines in a subprocess.Popen call changes behavior if stderr is also piped, as text mode affects both streams uniformly.
- If universal_newlines is passed as part of a **kwargs dict, the autofix may not apply, leaving deprecated usage intact.
- When universal_newlines is used in an asyncio subprocess function, the rewrite may be incorrect if the underlying API does not support 'text'.
- In subprocess.call, replacing universal_newlines with text alters behavior only if the Python version is < 3.7, where 'text' is unavailable and causes a TypeError.
- If the value of universal_newlines is a non-boolean (e.g., integer or expression), rewriting to text may change type expectations in downstream code relying on strict bool checks.
- Comments attached to the universal_newlines argument may be lost during rewrite if the tool does not preserve inline or trailing comments.
- When universal_newlines is used in a subprocess.run call with input as bytes, setting text=True may cause encoding/decoding errors if input is not valid UTF-8.
- If universal_newlines is aliased via import or assigned to another name (e.g., un = universal_newlines), the autofix won't trigger, creating inconsistent code.
- In a context where subprocess is shadowed by a local variable, the rewrite may fail to apply or apply incorrectly due to faulty name resolution.
- If the code is run under Python 3.6 or earlier, replacing universal_newlines with text will raise a TypeError because 'text' does not exist in those versions.
- Rewriting universal_newlines in a variadic call (e.g., *args, **kw) where kw is dynamically built may not be safe if the dict is shared or reused elsewhere.
- When universal_newlines is set conditionally via a ternary expression, the autofix may not preserve formatting, leading to style inconsistencies.
Programs
| id | result | title | hazard |
|---|