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
Really strange behavior here, when this statement is on the module level it creates a silently unreachable branch, but when in a scope it doesn't create unreachable
Maybe it'd be good to refer to the latter as something different than "reachability"
So, except for this hack, which is intended to reduce the indent in this case
import sys
-if sys.platform == 'windows':- <rest of file>+assert sys.platform == 'windows'+<rest of file>
we don't treat platform/version checks as reachability cues at all (otherwise you'd have to play error whack-a-mole, since if your code has an if-else for two platforms, one would always be unreachable).
💡 Here's an idea: The #5894 feature is intended to designate an entire module as unfit on other platforms. One clearly has to import sys before this assertion, but it's probably not needed to execute any other statements except for imports, so how about:
Continue working as-is if it appears after import statements only.
If other statements were seen before it, then it'll be an error, e.g.
importsysdeff() ->None: ...
assertsys.platform=='windows'# E: Module-level platform assertions must appear at the beginning of the module (before other statements)
Really strange behavior here, when this statement is on the module level it creates a silently unreachable branch, but when in a scope it doesn't create unreachable
playground
Related #11438
Related #11361
The text was updated successfully, but these errors were encountered: