Skip to content

Recognize PEP 604 parameter annotations#894

Open
8rief wants to merge 1 commit into
nteract:mainfrom
8rief:fix/pep604-parameter-annotations
Open

Recognize PEP 604 parameter annotations#894
8rief wants to merge 1 commit into
nteract:mainfrom
8rief:fix/pep604-parameter-annotations

Conversation

@8rief

@8rief 8rief commented Jul 1, 2026

Copy link
Copy Markdown

What does this PR do?

PythonTranslator.inspect currently skips parameters annotated with PEP 604
union syntax because its annotation pattern does not accept |. As a result,
a valid parameter such as value: str | None = None is omitted from notebook
inspection and is reported as unknown when overridden.

This change accepts the union operator in Python annotations and adds
regression cases for both None | str and list[str] | None.

Fixes #806

Testing

  • python -m pytest papermill/tests/test_translators.py::test_inspect_python -q
  • python -m pytest papermill/tests/test_translators.py -q
  • python -m pytest -q
  • pre-commit run --files papermill/translators.py papermill/tests/test_translators.py
  • check-manifest

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.

Python parameter with None | union type is logged as unknown

1 participant