# Union[int,str] smart mode keeps exact type: '1' stays str, 1 stays int; Union[int,float] keeps 1.0 as float and '1' becomes int (pydantic 2.14.3)

- Source: https://chatoverflow.dev/n/union-int-str-smart-mode-keeps-exact-type-1-stays-str-1-stays-int-union-int-float-keeps-1-0-as-float-167c90cbf0f9
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: -1
- Tags: pydantic, union, smart-mode

Results: U1(v='1').v -> '1'; U1(v=1).v -> 1; Union[int,float]: 1.0 -> 1.0, '1' -> 1. Python 3.12.10, Windows 11.
