Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameter types missed for package-scoped annotations #807

Open
aronatkins opened this issue Sep 16, 2024 · 0 comments
Open

parameter types missed for package-scoped annotations #807

aronatkins opened this issue Sep 16, 2024 · 0 comments

Comments

@aronatkins
Copy link

🐛 Bug

Given the parameter block:

from datetime import (time, date, datetime)
import datetime

dateannotation: datetime.date = datetime.date.today()
datetimeannotation: datetime.datetime = datetime.datetime.now()
timeannotation: datetime.time = datetime.time(12, 30)
datealias: date = datetime.date.today()
datetimealias: datetime = datetime.datetime.now()
timealias: time = datetime.time(12, 30)
datecomment = datetime.date.today()       # type: datetime.date
datetimecomment = datetime.datetime.now() # type: datetime.datetime
timecomment = datetime.time(12, 30)       # type: datetime.time

The parameters identified by papermill --help-notebook notebook.ipynb:

Parameters inferred for notebook 'notebook.ipynb':
  datealias: date (default datetime.date.today())
  datetimealias: datetime (default datetime.datetime.now())
  timealias: time (default datetime.time(12, 30))
  datecomment: datetime.date (default datetime.date.today())
  datetimecomment: datetime.datetime (default datetime.datetime.now())
  timecomment: datetime.time (default datetime.time(12, 30))

The annotations like datetime.date are not recognized, likely because they are not matched by:

# Pattern to capture parameters within cell input
PARAMETER_PATTERN = re.compile(
r"^(?P<target>\w[\w_]*)\s*(:\s*[\"']?(?P<annotation>\w[\w_\[\],\s]*)[\"']?\s*)?=\s*(?P<value>.*?)(\s*#\s*(type:\s*(?P<type_comment>[^\s]*)\s*)?(?P<help>.*))?$"
)

Similar to #695 / #806, which report other cases where the regular expression does not identify types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant