Skip to content

converter not running? #1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dlovell opened this issue May 29, 2023 · 1 comment
Closed

converter not running? #1137

dlovell opened this issue May 29, 2023 · 1 comment

Comments

@dlovell
Copy link

dlovell commented May 29, 2023

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'))
@dlovell
Copy link
Author

dlovell commented May 29, 2023

derp, I was using :, not =

@dlovell dlovell closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant