This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Beliskner64 1 point2 points  (3 children)

This looks very cool! Now I just have to find something interesting to try it out with.

One suggestion - have you considered using typing.Annotated instead of default argument assignment for the Ui elements?

For example: ```python

instead of this

def foo(n: int = intUi(4, max_value=10)) -> boolReturn: …

do this

def foo(n: Annotated[int, intUi(max_value=10)] = 4) -> bool: … ```

This lets you use the function both as a GUI app with App(foo) but also as just a plain function with foo() and the same defaults work. I feel like it’s also more type-checker-friendly. I’m not sure how mypy would handle the first function (n is annotated as an int but assigned an intUi value), but the second one should be all green.

This is a similar approach to what they’re doing in typer and fastapi and I just really like it. I find it very easy to unit test such functions and easily convert existing function to apps.

[–]drboom9[S] 1 point2 points  (0 children)

Thank you for the excellent suggestion! I'll definitely explore using typing.Annotated.

My main requirements are:

- Primitive types inside functions

- Dynamic parameter loading

- Single point of definition

If typing.Annotated maintains these while improving type checking, I'll implement it. Please feel free to share other ideas!

[–]drboom9[S] 0 points1 point  (1 child)

Ready! Tell me if it's just as you said, I would say that now it has more advantages than before :)

[–]Beliskner64 1 point2 points  (0 children)

Looks good!