Skip to content

converter not running? #1137

@dlovell

Description

@dlovell

When I run the script below, I get the subsequent terminal output.

The print of c0 shows that the dates field is not a tuple.

Notably, the validator does not seem to be catching that dates is not a tuple.

Is there anything obviously wrong I'm doing here?

import pandas as pd

import attr
from attr import (
    field,
    frozen,
)
from attr.validators import (
    instance_of,
    deep_iterable,
)


@frozen
class Calendar0:
    dates: field(validator=deep_iterable(instance_of(pd.Timestamp), instance_of(tuple)), converter=tuple)


print(f'attr version: {attr.__version__}')
dti = pd.date_range('2023-01-01', freq='D', periods=10)
c0 = Calendar0(dti)
print(c0)
attr version: 22.2.0
Calendar0(dates=DatetimeIndex(['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04',
               '2023-01-05', '2023-01-06', '2023-01-07', '2023-01-08',
               '2023-01-09', '2023-01-10'],
              dtype='datetime64[ns]', freq='D'))

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