Skip to content

[Python] cast() default discrepancy #55652

Open

Description

@AlenkaF

cast methods have safe=None in their signatures, but the docstrings specify the default as True:

def cast(arr, target_type=None, safe=None, options=None, memory_pool=None):
"""
Cast array values to another data type. Can also be invoked as an array
instance method.
Parameters
----------
arr : Array-like
target_type : DataType or str
Type to cast to
safe : bool, default True
Check for overflows or other unsafe conversions

Same in Array.cast, ChunkedArray.cast, RecordBatch.cast, Table.cast, Scalar.cast and Expression.cast.

None does get turned into True unless options is given but I would think the default should still match. Maybe we could use None in the docstring also and add "None behaves like True." note?

Found this while reviewing #55264.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions