Type checking + autocomplete don't work with the Linen API
See original GitHub issueModules in Linen are defined similar to dataclasses yet they aren’t dataclasses as such so the type checkers and the IDEs have no way on knowing what arguments each Module expects. This yields a lot of type checking errors and makes it harder to get automatic documentation.
Since the API is new maybe this could be taken into consideration early to avoid changes in the future.
Also, how does one perform logic similar to the one you would do in __init__
in this API? I know about setup
but sometimes you e.g. accept union types in the constructor and transform them to a standardize type for a field.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:16 (4 by maintainers)
Top Results From Across the Web
typeahead.js autocomplete is not showing any suggestions ...
I can see that while typing the name in customer textbox there is a call to my API but nothing is getting displayed...
Read more >How to Make an Auto Complete Search Input in React.js
In this video, I've shown you how can you make your own auto-complete search address input in react using an npm library ...
Read more >New, "Improved" Places SDK. PlacePicker deprecated! No ...
I just got an email detailing changes to the Places SDK. Of interest to me is that the PlacePicker is now deprecated, and...
Read more >HTML attribute: disabled - HTML: HyperText Markup Language
The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form.
Read more >Type checking and auto-completion in Plunker - AG Grid Blog
No more will you be left scratching your head wondering why a demo is not working due to a typo! Catch Type Errors....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The pyright team has a proposal for how to specify “dataclass-like semantics” for custom classes, which would solve the problem in this issue. They intend to submit this as a PEP, but they have also already implemented this spec in pyright and pylance, so VS Code users can directly make use of it. pydantic has a PR for supporting this spec.
Would the flax team be open to supporting this? As far as I can tell, it just involves creating a decorator called
__dataclass_transform__
(that doesn’t do anything at runtime) and applying it to the base class.FYI: The dataclass transform PEP is now in draft.
I mentioned Flax’s dataclass during the discussion, and they agreed to support applying the decorator to classes directly (instead of just to metaclasses), and pyright has already implemented that suggestion.