Open issue: introspection
: module name, sane defaults
#15
Labels
open issues
Open issues to be discussed with other users of the runtime typing ecosystem
The
introspection
is meant to be provide high-level utilities to inspect annotations at runtime.The current module name could be changed. Any ideas?
There are two functions —
get_literal_values()
andinspect_annotation()
— that can unpack PEP 695 type aliases. When such type aliases are encountered, you generally don't need to unpack them eagerly. For instance, with the following:You can retrieve the value of the
MyInt
alias only when processing the class argument oflist
.However, there are cases where having type aliases eagerly unpacked is beneficial. For instance:
The
@my_dataclass
implementation could benefit from havingMyInt
eagerly unpacked, so that it can detect the field alias early in the class creation (in Pydantic, this happens in the first class creation step, fields collection. We then have a step to generate the type validation logic, and realizing that the annotated metadata contains field metadata such as aliases isn't ideal).For this reason, the default value for
unpack_type_aliases
is to unpack them eagerly. However, this makes the functions unsafe asNameError
s can happen. Probably we should switch toskip
as a default value, but recommend usingeager
.The text was updated successfully, but these errors were encountered: