#Typing Errors when importing the dagger SDK due to beartype 0.18

1 messages · Page 1 of 1 (latest)

sour iris
#

Hello all, I'm running into issues with my pipelines caused by BearType, that seem to happen just when I'm trying to import the Dagger Python SDK. The exceptions all trace back to just the lines saying from dagger import ...
This is 'pre-zenith' style dagger code, just pipelines I'm executing directly rather than modules. What's weird is that even with previously working versions of the SDK (0.9.8), I'm still seeing the exceptions, so I'm not sure what's going on here...

sour iris
#

As a note, it's not related to the latest beartype release, because I still see this error even if I downgrade...

sour iris
#

I'm digging into this further, and getting some very frustrating errors. I can resolve the warnings about forward references by making all forward references in generic types explicit (e.g. Sequence["Container"] -> Sequence["dagger.client.gen.Container"]), but now I'm also headbutting against string enum defaults where Beartype is complaing that e.g. "media_types" default value 'OCIMediaTypes' violates type hint dagger.client.gen.ImageMediaTypes | None, as str 'OCIMediaTypes' not <class "builtins.NoneType"> or <protocol "dagger.client.gen.ImageMediaTypes">; I'm wondering, is there some kind of configuration setting for beartype I'm missing that will squash this kind of behaviour?

For reference, I'm running Python 3.11 and testing this with dagger 0.10.3

#

Ugh virtualenvs. Okay, so this is related to Beartype v0.18, very sorry for the spam

#

Typing Errors when importing the dagger SDK due to beartype 0.18

plush junco
#

cc @torn thistle

sour iris
#

From checking the release notes, looks like the default checks are definitely expected in 0.18 and are probably a constraint of using a str/enum mixin for backwards compatibility instead of the new StrEnum type 😌 The forward-references are somewhat less expected.

I don't want to just open a PR on gen.py as of course this is generated code, and how it ends up in the sdk from the GraphQL spec is something I'm not totally clear on 🙂

torn thistle
naive phoenix
#

Also running into this, any success with downgrading beartype?

torn thistle
#

This latest beartype version includes a change I contributed that fixes autocomplete for PyCharm users, so I really want to be able to fix this before next release.

naive phoenix
#

is there an ETA on releasing this fix?

torn thistle
#

Nope. Looking at it. I know what the issue is, I'm seeing if there's a way to ignore this particular exception.

#

https://github.com/dagger/dagger/pull/6297 introduced a few issues with default values. I was aware of [] being in defaults but wasn't too worried because the client doesn't mutate these values. Apparently beartype wasn't checking default values but now it does and surfaced another case that I wasn't aware of (in enums). So I'm using the warnings from beartype to find these. Already fixed locally so now I'm looking into the final thing which is just making beartype ignore forward references.

GitHub

This PR swaps out our GraphQL server infrastructure for DagQL.
notable changes

All objects are now ID-able. This is enforced by DagQL itself. They automatically get a FooID scalar type and a loadF...

naive phoenix
#

thanks, is there a suggested workaround for now? It sounds like downgrading dagger version doesn't help. I just need to get our pipelines unblocked

torn thistle
#

In dagger's next version dependencies will be pinned by default for new modules.

forest grotto
#

This issue seems to prevent me from creating a new module using --sdk=python is there a workaround for init as well?

static kelp
#

Hello, pinning beartype version fixed the issue for me beartype==0.17.2

torn thistle
torn thistle
forest grotto
exotic raptor
#

I also ran into this error today

chilly zealot
#

pinning beartype version 0.17.2 did not work for me

torn thistle
#

Beartype released 0.18.2 just now, which reverts the breaking change, so if you try again (without the pin) it should work.

chilly zealot
#

works now thanks