A casting version of the int trait.
| 2664 | |
| 2665 | |
| 2666 | class CInt(Int[G, S]): |
| 2667 | """A casting version of the int trait.""" |
| 2668 | |
| 2669 | if t.TYPE_CHECKING: |
| 2670 | |
| 2671 | @t.overload |
| 2672 | def __init__( |
| 2673 | self: CInt[int, t.Any], |
| 2674 | default_value: t.Any | Sentinel = ..., |
| 2675 | allow_none: Literal[False] = ..., |
| 2676 | read_only: bool | None = ..., |
| 2677 | help: str | None = ..., |
| 2678 | config: t.Any | None = ..., |
| 2679 | **kwargs: t.Any, |
| 2680 | ) -> None: |
| 2681 | ... |
| 2682 | |
| 2683 | @t.overload |
| 2684 | def __init__( |
| 2685 | self: CInt[int | None, t.Any], |
| 2686 | default_value: t.Any | Sentinel | None = ..., |
| 2687 | allow_none: Literal[True] = ..., |
| 2688 | read_only: bool | None = ..., |
| 2689 | help: str | None = ..., |
| 2690 | config: t.Any | None = ..., |
| 2691 | **kwargs: t.Any, |
| 2692 | ) -> None: |
| 2693 | ... |
| 2694 | |
| 2695 | def __init__( |
| 2696 | self: CInt[int | None, t.Any], |
| 2697 | default_value: t.Any | Sentinel | None = ..., |
| 2698 | allow_none: bool = ..., |
| 2699 | read_only: bool | None = ..., |
| 2700 | help: str | None = ..., |
| 2701 | config: t.Any | None = ..., |
| 2702 | **kwargs: t.Any, |
| 2703 | ) -> None: |
| 2704 | ... |
| 2705 | |
| 2706 | def validate(self, obj: t.Any, value: t.Any) -> G: |
| 2707 | try: |
| 2708 | value = int(value) |
| 2709 | except Exception: |
| 2710 | self.error(obj, value) |
| 2711 | return _validate_bounds(self, obj, value) # type:ignore[no-any-return] |
| 2712 | |
| 2713 | |
| 2714 | Long, CLong = Int, CInt |
no outgoing calls
searching dependent graphs…