Skip to content

[🐛 Bug]: [py] Platform detection code doesn't work well with type checker #16256

@cgoldberg

Description

@cgoldberg

Description

The Python bindings use platform.system() for detecting Windows to run platform-specific code in many places. This works fine, but we run into issues with our type checker (mypy). It doesn't respect platform.system(), so we get type errors in some of our platform-specific code when the type checker runs on other platforms. see: comments on #16250

mypy does do the right thing if you use sys.platform for platform detection instead:

https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks

We should investigate where we are using platform.system() and switch to sys.platform if possible.

Reproducible Code

if platform.system() == "Windows"

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pyPython BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions