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

Verify type hints for Bot method & class parameters #3868

Merged
merged 16 commits into from Sep 15, 2023

Conversation

harshil21
Copy link
Member

@harshil21 harshil21 commented Aug 31, 2023

Expands test_official by verifying that the type hints in our lib is same as TG API's.
Also changes type hint of user_id in bot methods from int | str to just int as specified by the API.

The change is breaking because PassportFile.file_date now accepts a datetime only, and its de_json now converts int -> datetime. No longer breaking.

Tests pass locally, seem to be failing here mysteriously

After review, before merge:

  • remove print statements

@harshil21
Copy link
Member Author

suggestions for optimizations / a different approach welcome btw

Base automatically changed from api-6.8 to master September 3, 2023 11:43
@harshil21 harshil21 marked this pull request as ready for review September 4, 2023 12:54
@harshil21 harshil21 added the breaking 💥 Breaking changes label Sep 4, 2023
@harshil21 harshil21 changed the title Verify type hints for Bot method parameters Verify type hints for Bot method & class parameters Sep 4, 2023
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Pfew, that is quite some code 🤯 I went through it once and left a bunch of comments, but I probably didn't get everything :D
I feel like as a follow-up of this PR, a refactoring of test_official into multiple modules is in order. I'll create an issue for that.

telegram/_bot.py Show resolved Hide resolved
telegram/_passport/passportelementerrors.py Outdated Show resolved Hide resolved
telegram/_passport/passportfile.py Outdated Show resolved Hide resolved
telegram/_payment/orderinfo.py Show resolved Hide resolved
tests/test_official.py Outdated Show resolved Hide resolved
tests/test_official.py Outdated Show resolved Hide resolved
tests/test_official.py Outdated Show resolved Hide resolved
tests/test_official.py Outdated Show resolved Hide resolved
tests/test_official.py Outdated Show resolved Hide resolved
Also don't collect test_official on py < 3.10
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Thanks for the updates :)

telegram/_passport/passportelementerrors.py Outdated Show resolved Hide resolved
telegram/_passport/passportelementerrors.py Outdated Show resolved Hide resolved
telegram/_passport/passportfile.py Outdated Show resolved Hide resolved
telegram/_passport/passportfile.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

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

Thanks for the new updates :) I don't think I have any more comments left - great job with Harshil, I continue to be amazed by your patience with test optimization 👏

Does anyone else want to review?

Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

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

I didnt catch an error, great job with the official extension!

Copy link
Member

@lemontree210 lemontree210 left a comment

Choose a reason for hiding this comment

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

I am NOT picking on function docstrings containing a third-person verb instead of imperative 😆

Very impressive indeed. I think that there could be some intersections in functionality with our admonition inserting tools, but that's just a thought.

telegram/_bot.py Outdated Show resolved Hide resolved
tests/test_official.py Outdated Show resolved Hide resolved
Copy link
Member

@lemontree210 lemontree210 left a comment

Choose a reason for hiding this comment

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

Thank you!

@Bibo-Joshi
Copy link
Member

Deepsource failure is unrelated. Merging once other tests pass

@Bibo-Joshi Bibo-Joshi merged commit 39abf83 into master Sep 15, 2023
22 of 23 checks passed
@Bibo-Joshi Bibo-Joshi deleted the improve-test-official branch September 15, 2023 19:33
@Bibo-Joshi
Copy link
Member

Awesome addition! thanks a lot :)

@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants