You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python version (& distribution if applicable, e.g. Anaconda): Python 3.10.12
Problem
Pylance reports that the condition process.stdout is None will always evaluate to False since the types "bytes" and "None" have no overlap. This is not true; process.stdout can actually be None in some cases.
It looks like you've enabled the reportUnnecessaryComparison check. This check is off by default in "basic" and "standard" type checking mode. That means you've either enabled "strict" type checking mode or manually enabled this specific check. If you do not want to see diagnostics for this check, you can leave it disabled.
When this check is enabled, pyright (the type checker that pylance is built upon) reports cases where a conditional expression always evaluates to True or False. In this case, the expression process.stdout is None always evaluates to False based on type analysis. That's because the call to subprocess.run returns a value of type CompletedProcess[bytes], and the type of process.stdout evaluates to type bytes. That means it can never be None.
This type analysis is performed based on type information provided in the type stubs provided by the typeshed project. If you think that there is an error in these typeshed stubs, please report the error to the maintainers of typeshed.
In any case, pyright is working as intended here. The reportUnnecessaryComparison check is correctly identifying and reporting a conditional check in your code that (according to type analysis) will always evaluate to False, which may indicate that you have a bug in your code.
Environment data
Problem
Pylance reports that the condition process.stdout is None will always evaluate to False since the types "bytes" and "None" have no overlap. This is not true; process.stdout can actually be None in some cases.
Code Snippet
Repro Steps
Expected behavior
No warning should occur on line 3
Actual behavior
A warning occurs
The text was updated successfully, but these errors were encountered: