Skip to content

Conversation

@msullivan
Copy link
Member

Currently, doing == on arrays fails at runtime with

AttributeError: type object 'Array[models.__sharedstd__.__shapes__.std.uuid]' has no attribute '__gel_type_class__'

and produces a bool at typecheck time instead of a type[std.bool].

My approach to fixing this is to replace uses of Array with
std.array, which has a __gel_type_class__ and all the appropriate
overloadings.

When I extend this approach to other similar types, though, like
Range, I run into problems: the typing_dispatch based overloaded
constructor for range always fails when doing a
Type.model_validate(r.model_dump()), in part because the overloads
all seem to want want std.bool and won't accept real bools.

@elprans Does this seem like the right approach, and I should continue
down this path and fix any problems in the way (like those mentioned
above), or do you think I'm on the wrong track here?

Currently, doing `==` on arrays fails at runtime with
```
AttributeError: type object 'Array[models.__sharedstd__.__shapes__.std.uuid]' has no attribute '__gel_type_class__'
```
and produces a `bool` at typecheck time instead of a `type[std.bool]`.

My approach to fixing this is to replace uses of `Array` with
`std.array`, which has a `__gel_type_class__` and all the appropriate
overloadings.

When I extend this approach to other similar types, though, like
`Range`, I run into problems: the `typing_dispatch` based overloaded
constructor for range always fails when doing a
`Type.model_validate(r.model_dump())`, in part because the overloads
all seem to want want `std.bool` and won't accept real bools.

@elprans Does this seem like the right approach, and I should continue
down this path and fix any problems in the way (like those mentioned
above), or do you think I'm on the wrong track here?
@elprans
Copy link
Member

elprans commented Sep 30, 2025

Does this seem like the right approach, and I should continue
down this path and fix any problems in the way (like those mentioned
above), or do you think I'm on the wrong track here?

yeah, that's how I would do it

@msullivan msullivan merged commit 22f84b3 into master Sep 30, 2025
43 checks passed
@msullivan msullivan deleted the arrays branch September 30, 2025 17:55
msullivan added a commit that referenced this pull request Oct 3, 2025
Generate `std.range`/`std.tuple`, follownig the approach of #939.

Then, fix calling functions in QB when range[_T_anypoint] or
array[_T_anytype] used, by specifically checking ParametricType
subclasses against GenericAlias[T].
msullivan added a commit that referenced this pull request Oct 3, 2025
Generate `std.range`/`std.tuple`, follownig the approach of #939.

Then, fix calling functions in QB when range[_T_anypoint] or
array[_T_anytype] used, by specifically checking ParametricType
subclasses against GenericAlias[T].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants