Skip to content

Problems when Union contains Callable Typehint #74

@saknarf

Description

@saknarf

Example Code:

from datetime import datetime
from typing import Callable, Union

from pedantic import frozen_dataclass


@frozen_dataclass
class DatetimeCallable:
    dt: datetime | Callable[[], datetime]


if __name__ == '__main__':
    x = DatetimeCallable(
        dt=datetime(year=2022, month=1, day=1),
    ).validate_types()

Exception:

TypeError: datetime.datetime(2022, 1, 1, 0, 0) is not a callable object

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions