Skip to content

type hint: Make Optional explicit (PEP 484)#873

Open
bact wants to merge 2 commits intospdx:mainfrom
bact:make-optional-explicit
Open

type hint: Make Optional explicit (PEP 484)#873
bact wants to merge 2 commits intospdx:mainfrom
bact:make-optional-explicit

Conversation

@bact
Copy link
Contributor

@bact bact commented Jan 16, 2026

PEP 484 prohibits implicit Optional.
https://peps.python.org/pep-0484/#union-types

This PR updates type hints from:

def f(document: Document = None) -> Any:

to

def f(document: Document | None = None) -> Any:

Note that this mass conversion is done automatically by https://github.com/hauntsaninja/no_implicit_optional as suggested by mypy, with a human review.

Uses ... | None style instead of Optional[...] since we are now using Python 3.10.

bact added 2 commits January 16, 2026 09:53
PEP 484 prohibits implicit Optional.

Note that this mass conversion is done automatically by https://github.com/hauntsaninja/no_implicit_optional as suggested by mypy, with a human review.

Uses `... | None` style instead of `Optional[...]` since we are now using Python 3.10.

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant