Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added type conversions (built-ins -> hiku types), as the first step of class-based API implementation.
For now covering built-in scalars (int, float, bool, str) + containers (list, optional) + typerefs for custom object types. With the refs to python classes cyclic imports become a real problem, so I added
lazy
annotation for that purpose (influenced by strawberry). I was not too concerned about python versioning so far - I will use propertyping_extension
imports and so on after the basic stuff is ready and working.My main concern is being able to gradually update existing definitions with class-based API - for that purpose
raw_type
annotation was added. Basicallyraw_type
could be all we need to start writing classes, thoughtyping.Annotated
stuff does look cumbersome - that's why I decided to cover some basic cases (scalars, containers, typerefs) too. Interfaces, unions, enums, custom scalars (includinghiku.types.ID
andhiku.types.Any
) for now require the use ofraw_type
. Later there should be no problems implementing interfaces via class inheritance, unions and custom scalars via type aliases, enums - usingenum
stdlib.For the next step, I plan to add transformations of class-based nodes to
hiku.graph.Node
. I believe, that it should go toGraph.__init__
: lazy imports should be able to resolve just fine there (cuz all nodes have to be imported anyway to be passed toGraph.items
). During transformation I plan to auto-transform field names to camelCase and add some default resolvers, all other params unchanged for now.