nteract/papermill

parameter types missed for package-scoped annotations

Open

#807 aberto em 16 de set. de 2024

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)Python (402 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (5.381 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

🐛 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: https://github.com/nteract/papermill/blob/0ee530d11b5d20c7fb8604bd021558970e369b64/papermill/translators.py#L144-L147

Similar to https://github.com/nteract/papermill/issues/695 / https://github.com/nteract/papermill/issues/806, which report other cases where the regular expression does not identify types.

Guia do colaborador