Skip to content

[BugFix][MyPy]: Module has no attribute "sched_getaffinity" [attr-defined]#41465

Merged
hmellor merged 2 commits intovllm-project:mainfrom
hickeyma:fix-mypy-error-cpu-res
May 5, 2026
Merged

[BugFix][MyPy]: Module has no attribute "sched_getaffinity" [attr-defined]#41465
hmellor merged 2 commits intovllm-project:mainfrom
hickeyma:fix-mypy-error-cpu-res

Conversation

@hickeyma
Copy link
Copy Markdown
Contributor

@hickeyma hickeyma commented May 1, 2026

Error when MyPy run locally:

$ pre-commit run -a --hook-stage manual mypy-3.10

Run mypy for Python 3.10.................................................Failed
- hook id: mypy-3.10
- exit code: 1

$ mypy --python-version 3.10 
vllm/utils/cpu_resource_utils.py:128: error: Module has no attribute "sched_getaffinity"  [attr-defined]
Found 1 error in 1 file (checked 1025 source files)

The solution uses sys.platform instead of platform.system() because MyPy only understands sys.platform for OS checks and not platform.system() as it can’t safely narrow types with platform. Updated the file in 61617d0 to use sys.platform for consistency.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added cpu Related to CPU backends bug Something isn't working labels May 1, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the get_allowed_cpu_list function in vllm/utils/cpu_resource_utils.py to explicitly check for the Linux platform before attempting to use os.sched_getaffinity. This change replaces a Darwin-specific check with a more robust Linux-specific check, ensuring compatibility across different operating systems where os.sched_getaffinity might not be available. I have no feedback to provide.

hickeyma added 2 commits May 5, 2026 09:30
$ pre-commit run -a --hook-stage manual mypy-3.10

vllm/utils/cpu_resource_utils.py:128: error: Module has no attribute "sched_getaffinity"  [attr-defined]

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Use sys.platform instead throughout the file.

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
@hickeyma hickeyma force-pushed the fix-mypy-error-cpu-res branch from 61617d0 to 6f2f7f3 Compare May 5, 2026 08:31
Copy link
Copy Markdown
Member

@hmellor hmellor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@hmellor hmellor enabled auto-merge (squash) May 5, 2026 11:37
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 5, 2026
@hmellor hmellor merged commit 6fca518 into vllm-project:main May 5, 2026
48 checks passed
chaojun-zhang pushed a commit to chaojun-zhang/vllm that referenced this pull request May 6, 2026
…ined] (vllm-project#41465)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
amd-mghanimi pushed a commit to amd-mghanimi/vllm that referenced this pull request May 6, 2026
…ined] (vllm-project#41465)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Signed-off-by: Mehdi Ghanimifard <mehdi.ghanimifard@amd.com>
Copilot AI pushed a commit to hongbolv/vllm that referenced this pull request May 7, 2026
…ined] (vllm-project#41465)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Co-authored-by: hongbolv <33214277+hongbolv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cpu Related to CPU backends ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants