-
Notifications
You must be signed in to change notification settings - Fork 55
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 #82
Comments
Should we use stubs files or add type annotations in the source code? |
I haven't used stubs much, just type annotations. I'm not sure how much benefit we'd get for using stubs? If you have more experience on that would love an opinion.
Yep |
Wait you mean we shouldn't interweave traitlets everywhere? |
(that is a joke, I think it's a good idea) |
I don't have any experience in type annotation, but I'm thinking that the Jupyter projects will need to exchange type definition, right? Like nbclient will probably need a definition of a |
Doesn't need a type stub -- you can just import the class and use it in the annotation inline. The inline annotations actually read better for expectations. For example:
works just fine |
I actually don't know how traitlets play with type annotations... that would be something to figure out I guess (joke aside) |
my (poor) understanding of traitlets is that one of the reasons it was developed was to allow you to type inputs, so I think (?) to some degree they replicate functionality |
Yes but traitlets validate type at runtime, it's not static type analysis. |
They also provide a config interface for assignment from file / cml args. |
ok ok I apologize for throwing shade at traitlets :-) |
lol, I don't particularly like the traitlet model either as it uses less than ideal software practices to achieve (high complexity in tracing, 10+ class inheritance chains, makes init operations more complex, very obscure error message patterns when it fails, unexpected config inheritance patterns, etc) -- which I've been vocal about. I'd prefer removing traitlets from nbclient if we could. I've left them when porting over because the file based config is used very very heavily in nbconvert and the users who use it like it a lot. So removing it from nbclient would require mapping that in nbconvert in the preprocessor layer... might be worth discussing doing before 1.0 of nbclient and 6.0 of nbconvert fully ship? Would be tough to choose. |
I guess if we just wanted the CLI part of traitlets, we could use click. But there's also the reactive part in traitlets (observing changes). |
(I'm a big fan of click) |
I have started to work on it in #83. |
Fixed in #83 |
We're on python 3 only, let's make use of type annotations on our functions.
The text was updated successfully, but these errors were encountered: