Closed florianfischer91 closed 2 years ago
I'm unclear about the use-case for a boolean field, as boolean terms don't appear very often in ASP programs. In most cases that I can think of, there would be a more compact way to encoding things.
It could still be useful but I'm a bit wary of having it in the core fields. I wonder if it would make more sense to put it in lib
along with the date field?
To make this work nicely I guess it would need an extra API function to core
to register type -> field matches. Something like register_field_type()
. This way adding extra fields could be done without touching core
, and users could potentially add their own fields or override the defaults.
Well the use-case is the same as for date or time, that you have a different representations in python and asp. Therefore i thought it would be a good idea to have it in clorm (especially because bool is a builtin type). So i can move it to lib and create a separate file bool.py
or boolean.py
(if you want to have it in clorm) otherwise i can also just add it to my own project.
Regarding the register function: I have already seen the related issue, but as long as there is no such functionality we have to touch core.py
^^
Well the use-case is the same as for date or time, that you have a different representations in python and asp. Therefore i thought it would be a good idea to have it in clorm (especially because bool is a builtin type). So i can move it to lib and create a separate file
bool.py
orboolean.py
(if you want to have it in clorm) otherwise i can also just add it to my own project. Regarding the register function: I have already seen the related issue, but as long as there is no such functionality we have to touchcore.py
^^
Ok, I think adding it to lib/bool.py
or lib/boolean.py
would be better. My feeling is that it wouldn't be used often, but useful to have when it is needed. I'll look more into the register function.
This PR adds support for
bool
to be used as a type annotation when defining a predicate classTo convert from/to
bool
the following lookups will be used (strings converted to lower case)If
StrictBool
is used, just integers0
and1
are allowedIn Python < 3.7
Union[bool,int]
is simplified toint
, so if you can't upgrade you can use the more stricter versionUnion[StrictBool, int]
instead.Also keep in mind when defining
Union
annotations, it's recommended to include the most specific type first and followed by less specific types