Accept dotted (module-qualified) type names in parameter annotations#872
Open
huyhoang171106 wants to merge 2 commits intonteract:mainfrom
Open
Accept dotted (module-qualified) type names in parameter annotations#872huyhoang171106 wants to merge 2 commits intonteract:mainfrom
huyhoang171106 wants to merge 2 commits intonteract:mainfrom
Conversation
…notations Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
…notations Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Python parameter inference so that PEP-526 style annotations using module-qualified (dotted) type names (e.g., datetime.date) are recognized during PythonTranslator.inspect, which in turn improves parameter discovery for --help-notebook.
Changes:
- Broadened the Python parameter-regex annotation matcher to allow
.in annotation tokens. - Added a regression test ensuring
PythonTranslator.inspectparses a dotted annotation correctly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
papermill/translators.py |
Expands PARAMETER_PATTERN to accept dotted type names in annotations. |
papermill/tests/test_translators.py |
Adds a unit test case covering datetime.date annotations during inspection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Python parameter inference logic currently misses annotated parameters when the annotation is package-scoped (for example
datetime.date,datetime.datetime,datetime.time). This causes--help-notebookto skip otherwise valid parameters declared with PEP-526 style annotations. The root cause is an overly restrictive annotation-matching regex that accepts only a single identifier token for the type.Files changed
papermill/translators.py(modified)papermill/tests/test_translators.py(modified)Testing
What does this PR do?
Fixes #<issue_number>
Closes #807