-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
thrift binary type converted into pyi string type #25
Comments
Hi, thanks for using it! Can you please tell what thrift version you're using? I do believe it is expected behaviour for thrifty (v1), but not for thriftpy2. |
Yeah I'm using thriftpy2, so it's a little bit confusing when I see errors from pyright. Do you consider it reasonable to enable byte anno from binary? Actually thriftpy2 is used a lot. |
I see. |
any follow-ups on this issue? thanks! |
I'm sorry it took me so long Prior thriftpy2 v0.4.13 BINARY and STRING are the same types. Since v0.4.13 BINARY is indeed a separate type and will be cast to So, my guess is that you should just update the thriftpy2 version to 0.4.13 or higher and you'll be fine |
We are using thriftpy v0.4.14 at work and still hitting this issue of binary types being inferred as Example protocol: struct Message {
1: binary body,
2: binary key,
3: optional i32 partition = -1,
4: optional i64 timestamp_micros = -1
} Generated type: @dataclass
class Message:
body: Optional[str] = None
key: Optional[str] = None
partition: Optional[int] = -1
timestamp_micros: Optional[int] = -1 interestingly, v0.4.14 has |
@matthewess As far as I can see they reverted separate BINARY type:
But right now it's back in the master branch, they just haven't made a release yet: So for now we just have to wait for a new release, because there is no way to distinguish between |
thriftpy2 now has a release with binary support (0.4.15/0.4.16). Do you plan to support this or are you open to pull requests? |
@JayH5 |
I've added support for binary types Feel free to re-open in case of any problem |
I really appreciate this awesome tool and it helped me a lot. But I just figure out that if a type is
binary
in thrift, it will be converted intostr
in pyi, instead ofbyte
. I wonder if this behavior is expected.The text was updated successfully, but these errors were encountered: