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

feat(cod-gen): change raw types generation to have proper typehints #130

Closed
wants to merge 3 commits into from

Conversation

Danipulok
Copy link

What this PR does?

  • Change generation of pyrogram/raw/base* files to get proper typehints;

MRE (code to check if everything works properly and shows typehints):

import asyncio

from pyrogram import Client, raw


async def main() -> None:
    client = Client(
        name="account",
        api_id=8,
        api_hash="7245de8e747a0d6fbe11f7cc14fcc0bb",
    )

    await client.start()

    peer_id = 111
    peer = await client.resolve_peer(peer_id)
    result: raw.types.messages.PeerDialogs = await client.invoke(
        raw.functions.messages.GetPeerDialogs(
            peers=[peer],
        )
    )

    print(result.dialogs[0].read_outbox_max_id)
    await client.stop()


if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

Before (current code) / After (PR):

Type hints:

Before:
image
After:
image

Generated file (single type):

Before:
image
image
After:
image

Generated file (unions):

Before:
image
image
After:
image

@Danipulok
Copy link
Author

Closed in favor of #151

@Danipulok Danipulok closed this Mar 10, 2025
@Danipulok Danipulok deleted the feat/code-gen branch March 10, 2025 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant