Skip to content

[multiprocessing] DefaultContext.get_start_method can return None - #16799

Open
vmphase wants to merge 1 commit into
python:mainfrom
vmphase:fix/multiprocessing-get-start-method-none
Open

vmphase wants to merge 1 commit into
python:mainfrom
vmphase:fix/multiprocessing-get-start-method-none

Conversation

@vmphase

@vmphase vmphase commented Nov 14, 2026

Copy link
Copy Markdown

multiprocessing.get_start_method(allow_none=True) returns None when no start method has been set (docs, source). Hence, code that handles this documented case gets flagged by type checkers:

warning: Condition will always evaluate to False since the types "str" and "None" have no overlap (reportUnnecessaryComparison)

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@overload
def get_start_method(self, allow_none: Literal[False] = False) -> str: ...
@overload
def get_start_method(self, allow_none: bool) -> str | None: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def get_start_method(self, allow_none: bool) -> str | None: ...
def get_start_method(self, allow_none: Literal[True]) -> str | None: ...

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants