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...
#Typing Errors when importing the dagger SDK due to beartype 0.18
1 messages · Page 1 of 1 (latest)
As a note, it's not related to the latest beartype release, because I still see this error even if I downgrade...
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
cc @torn thistle
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 🙂
Yeah, just caught this in CI (#maintainers message).
Also running into this, any success with downgrading beartype?
Downgrading was done in https://github.com/dagger/dagger/pull/6993, now I'm trying to fix. I don't like how beartype wants me to use full paths in forward references when it's types from the current file!
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.
yea I really like beartypes philosophy/approach but there seem to be some sharp edges to it
is there an ETA on releasing this fix?
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.
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
Just pin beartype in your module's pyproject.toml:
dependencies = ["beartype==0.17.2"]
(or "beartype<0.18")
In dagger's next version dependencies will be pinned by default for new modules.
As part of https://github.com/dagger/dagger/pull/6884
This issue seems to prevent me from creating a new module using --sdk=python is there a workaround for init as well?
Hello, pinning beartype version fixed the issue for me beartype==0.17.2
Yes, but you need to create a pyproject.toml before doing init.
I tried this but it didn’t work for me unfortunately 😦 I can hold on for the update though
I also ran into this error today
pinning beartype version 0.17.2 did not work for me
Beartype released 0.18.2 just now, which reverts the breaking change, so if you try again (without the pin) it should work.
works now thanks