Skip to content

Conversation

@texodus
Copy link
Member

@texodus texodus commented Nov 15, 2024

This PR adds support for using native Python types as column type specifiers, when creating a Perspective Table from a schema. The available types are based on the types allowed in 2.10.1:

table = perspective.table({
    "integer": int,
    "float": float,
    "string": str,
    "boolean": bool,
    "date": datetime.date,
    "datetime": datetime.datetime,
})

It is worth noting that despite the use of date and datetime python types as schema specifiers for legacy support, 3.x does not support date or datetime values when provided to the table constructor function in a dict or list input type (though you may extend native json parsing to allow this, or use pandas.DataFrame to marshall these to for you, see the 3.x release notes).

This support is a convenience feature for existing integrations with the old API. Unlike the old API, Table::schema and View::schema (and all existing and future APIs that use Perspective visual types) will only return String.

Also fixed, PerspectiveWidget was moved to a sub-module in #2728, but the reference to this class was left in the root __init__.py's __all__ variable. A test for this has been added as well - which may seem a bit ham-fisted, but even perspective's own repo lacked a test-path which included from perspective import * to expose this case beforehand, so ...

@texodus texodus added bug Concrete, reproducible bugs enhancement Feature requests or improvements and removed bug Concrete, reproducible bugs labels Nov 15, 2024
@texodus texodus marked this pull request as ready for review November 15, 2024 09:37
@texodus texodus force-pushed the python-schema-relax branch from 9fa3430 to 370548d Compare November 15, 2024 09:53
@texodus texodus merged commit d630f0f into master Nov 15, 2024
13 checks passed
@texodus texodus deleted the python-schema-relax branch November 15, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests or improvements

Development

Successfully merging this pull request may close these issues.

2 participants