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

type annotations for metainfo #56

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sneakers-the-rat
Copy link

@sneakers-the-rat sneakers-the-rat commented Feb 6, 2025

Hello :)

Very simple little PR, took me awhile to get a sense of the structure of the metainfo object, so thought i might as well contribute some type annotations for it.

typing_extensions dep is for the Required/NotRequired/total syntax which is only in >3.11, that's necessary to model the "anything can be in there but these are the keys that are usually in there" structure of that dict.

@Ravencentric
Copy link
Contributor

Ravencentric commented Feb 6, 2025

typing_extensions dependency is not required. Type checkers assume it's present in stub files regardless so you can use it without depending on it

pyproject.toml Outdated Show resolved Hide resolved
torf/_torrent.pyi Outdated Show resolved Hide resolved
@Ravencentric
Copy link
Contributor

I have only given it a quick look, I'll review it in depth soon.

torf/_torrent.pyi Outdated Show resolved Hide resolved
@Ravencentric
Copy link
Contributor

Ravencentric commented Feb 6, 2025

The typing part looks good to me (after you handle the requested changes), although @rndusr will still have to check if the structure defined by the typed dict matches the runtime

@sneakers-the-rat
Copy link
Author

check if the structure defined by the typed dict matches the runtime

I tried to go through and ctrl+f for different keys being added/removed, but i am sure that i missed some. sorry if i did! mypy doesn't complain at least?

@Ravencentric
Copy link
Contributor

check if the structure defined by the typed dict matches the runtime

I tried to go through and ctrl+f for different keys being added/removed, but i am sure that i missed some. sorry if i did! mypy doesn't complain at least?

don't worry, not saying you've got it wrong. I'm just not too familiar with the runtime semantics of metainfo to make a good judgement.

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.

2 participants