-
Notifications
You must be signed in to change notification settings - Fork 950
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
Add some missing typing in code #1448
Conversation
fac5e85
to
6b15a66
Compare
ref: #1430 Signed-off-by: Alexandre Lavigne <[email protected]>
6b15a66
to
f591810
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a lot to this ! you found some inspiration and a love of types. it is good effort :)
I have left a few comments
Some questions:
why was so much left untyped?
is there a json type? Is it Response
? Why do many of the return types use Any
instead of Response
?
I believe when we merge different branches we picked the code from the untyped branch and left it as-is.
No there is not 😢 We return Any because returning a JSON type is too complex. Mypy works with a static type, and no type heritage. Meaning: when you define a type like When you want to type some JSON and this JSON is a Dict with any kind of value, you must define all possible type you could expect: List[...], Mapping[..., ...], str, int, .... and for each List[X] you must define what could be inside, so again you must provide all possible types.... In the end it's exactly the same as Any which in short means -> it could be any type. there is a huge github issue on the official python/typing repo about JSON, the very first comment shows a very clear example of what we need (but don't have): python/typing#182 In the mean time, we are left with Any |
Now that I checked the issue again, I found this ! https://github.com/kevinheavey/jsonalias which could do the trick. I would recommend we first merge this like this, then later in a second PR we change all Any to some |
all great reasoning. mypy has whims and we must conform to them lgtm :) |
Introduce a lot of
Any
Typing is most method in theSpreadsheet
object return some JSON object and we can't type it.ref: #1430