basxsoftwareassociation / bread

Engine to create database applications based on Django and the IBM Carbon Design System
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

add typechecking of the package `bread/forms` to the CI #115

Closed wipascal closed 2 years ago

wipascal commented 2 years ago

Okay, a lot of comments, I think some of the issues might also originate from when I wrote annotations the first time.

Another thing I wonder is: Could it make sense that we implement our own type (see https://docs.python.org/3/library/typing.html#user-defined-generic-types) for the cases where we use htmlgenerator.Lazy? I hope we could write Lazy[str] or Lazy[Any] and similar instead of always skipping or using Union.

1. We express the expected type of the Lazy expression

2. No need to always think the "non-lazy" option.

I like the idea of introducing "shortcuts" for the types. They can get very verbose...

But Lazy[str] to me just looks like a Lazy that evaluates to a string and not like Union[Lazy, str]. For me we would need to call it MaybeLazy[str] or something like that.

(Actually I like the idea of using Lazy[T] for a Lazy that evaluates to T, but that's a different topic altogether.)

saemideluxe commented 2 years ago

Okay, a lot of comments, I think some of the issues might also originate from when I wrote annotations the first time. Another thing I wonder is: Could it make sense that we implement our own type (see https://docs.python.org/3/library/typing.html#user-defined-generic-types) for the cases where we use htmlgenerator.Lazy? I hope we could write Lazy[str] or Lazy[Any] and similar instead of always skipping or using Union.

1. We express the expected type of the Lazy expression

2. No need to always think the "non-lazy" option.

I like the idea of introducing "shortcuts" for the types. They can get very verbose...

But Lazy[str] to me just looks like a Lazy that evaluates to a string and not like Union[Lazy, str]. For me we would need to call it MaybeLazy[str] or something like that.

(Actually I like the idea of using Lazy[T] for a Lazy that evaluates to T, but that's a different topic altogether.)

Right, MaybeLazy[T] and Lazy[T] would be interesting, if somebody needs something recreational to do, that could be added in htmlgenerator ;)