flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

[Python][23.5.26] Type annotation for string fields incorrect

Open multiplemonomials opened this issue 2 years ago • 5 comments

When a field in a schema is declared as string, the Python code generator outputs a function declaration like:

    def MyField(self) -> Optional[str]:

However, the underlying implementation has always returned a bytes object for such getters. This means that the annotation is incorrect, and should be changed to say Optional[bytes].

multiplemonomials avatar May 31 '23 21:05 multiplemonomials

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Nov 30 '23 20:11 github-actions[bot]

not-stale

multiplemonomials avatar Dec 01 '23 03:12 multiplemonomials

I think the code that needs to be fixed is here: https://github.com/google/flatbuffers/blob/5ba80c24e09ab4a34c14a8dae225eb222b58ebe7/src/idl_gen_python.cpp#L1081 and here: https://github.com/google/flatbuffers/blob/5ba80c24e09ab4a34c14a8dae225eb222b58ebe7/src/idl_gen_python.cpp#L1128

multiplemonomials avatar Dec 01 '23 03:12 multiplemonomials

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar May 31 '24 20:05 github-actions[bot]

not-stale

multiplemonomials avatar Jun 01 '24 01:06 multiplemonomials