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

Annotate json.py #1529

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

dobosevych
Copy link
Contributor

The part of #1511

@dobosevych dobosevych marked this pull request as draft April 14, 2022 06:54
@Kludex
Copy link
Contributor

Kludex commented Apr 14, 2022

Thanks @dobosevych !

We need to work a little bit on those Any. Can we make them more precise?

I can try to help on those later on, if needed. 🙏

@auvipy auvipy added this to In progress in Type Hinting via automation Apr 14, 2022
@auvipy auvipy self-requested a review April 14, 2022 09:31
@dobosevych
Copy link
Contributor Author

@Kludex did one more iteration on this module. It would be great to have some feedback and what can be improved

@dobosevych dobosevych marked this pull request as ready for review April 16, 2022 10:18
Copy link
Contributor

@Kludex Kludex left a 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),
Copy link
Contributor

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,),
Copy link
Contributor

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,
Copy link
Contributor

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]:
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about it.
image

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

Successfully merging this pull request may close these issues.

None yet

2 participants