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

Replace Stats with TypedDicts and make Client & Job classes generic #14

Open
MinekPo1 opened this issue Mar 11, 2025 · 0 comments
Open

Comments

@MinekPo1
Copy link

MinekPo1 commented Mar 11, 2025

Hi! I really like how you wrote this library, but there are two minor things i would love to be improved when it comes to the modules type signatures you provided. Hope you don't mind me joining these two suggestions into one issue instead of creating two, but i felt this was more appropriate.

The first is to describe the output of the stat family of functions with TypedDicts, which allows static type checkers to get more information on the expected keys. Unfortunately they have been introduced in python 3.8, but if you want to continue supporting 3.7 they can be conditionally replaced with the same alias you are currently using.

The second small change i would really like is to make the Client and Job classes generic based on if the job bodies have been decoded or not, which will prevent type checkers from thinking each individual job can have a body which is either a string or bytes, while its effectively decided when the Client class is created. An additional bonus is that this can accommodate possible future changes to allow custom serializatiors and deserializators.

These changes shouldn't take long to implement and i can do have done so if you want.

MinekPo1 added a commit to MinekPo1/greenstalk that referenced this issue Mar 11, 2025
- `Client` and `Job` are now generic, indicating the type of the job
  body (only on the python side)
- on python 3.8 and above, use `TypedDict`s for the return value of the
  `stat` family of functions

see justinmayhew#14 (on github.com:justinmayhew/greenstalk) for motivation and more
verbose description
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

No branches or pull requests

1 participant