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
Annotate json.py
#1529
base: main
Are you sure you want to change the base?
Annotate json.py
#1529
Conversation
for more information, see https://pre-commit.ci
Thanks @dobosevych ! We need to work a little bit on those I can try to help on those later on, if needed. 🙏 |
for more information, see https://pre-commit.ci
@Kludex did one more iteration on this module. It would be great to have some feedback and what can be improved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a difficult file to annotate. I've added some comments, hope it helps.
I didn't finish the review, JFYK.
datetime=datetime.datetime, | ||
text_t=str): | ||
def default(self, o: Any, | ||
dates: Iterable = (datetime.datetime, datetime.date), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do: DateType = TypeVar("DateType", bound=datetime.date)
here.
text_t=str): | ||
def default(self, o: Any, | ||
dates: Iterable = (datetime.datetime, datetime.date), | ||
times: Iterable = (datetime.time,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analogous as above, I guess? Please confirm.
times: Iterable = (datetime.time,), | ||
textual: Any = (decimal.Decimal, uuid.UUID, DjangoPromise), | ||
isinstance: Callable = isinstance, | ||
datetime: Type[datetime.datetime] = datetime.datetime, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky... Maybe Type[DatetimeType]
, being DatetimeType = TypeVar("DatetimeType", bound=datetime.datetime)
?
textual: Any = (decimal.Decimal, uuid.UUID, DjangoPromise), | ||
isinstance: Callable = isinstance, | ||
datetime: Type[datetime.datetime] = datetime.datetime, | ||
text_t: Callable[[Any], str] = str) -> Union[str, Dict]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this union... 🤔
dates: Iterable = (datetime.datetime, datetime.date), | ||
times: Iterable = (datetime.time,), | ||
textual: Any = (decimal.Decimal, uuid.UUID, DjangoPromise), | ||
isinstance: Callable = isinstance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The part of #1511