zen-xu / pyarrow-stubs

Type annotations for pyarrow
BSD 2-Clause "Simplified" License
15 stars 14 forks source link

Is there a way to avoid redundant cast with DictionaryType #113

Closed deanm0000 closed 4 weeks ago

deanm0000 commented 1 month ago

Is there a way to do

if isinstance(array, pa.DictionaryType) and array.type.value_type:

Right now it's got to be

if isinstance(array.type, pa.DictionaryType)
        and cast(pa.DictionaryType, array.type).value_type
zen-xu commented 1 month ago

You can use TypeGuard

WeChat6b42be0a0903c3a4ddd41d75abc84a83