(self, obj: t.Any, value: t.Any)
| 2641 | ) |
| 2642 | |
| 2643 | def validate(self, obj: t.Any, value: t.Any) -> G: |
| 2644 | if not isinstance(value, int) and isinstance(value, numbers.Number): |
| 2645 | # allow casting integer-valued numbers to int |
| 2646 | # allows for more concise assignment like `4e9` which is a float |
| 2647 | try: |
| 2648 | int_value = int(value) |
| 2649 | if int_value == value: |
| 2650 | value = int_value |
| 2651 | except Exception: |
| 2652 | pass |
| 2653 | if not isinstance(value, int): |
| 2654 | self.error(obj, value) |
| 2655 | return _validate_bounds(self, obj, value) # type:ignore[no-any-return] |
| 2656 | |
| 2657 | def from_string(self, s: str) -> G: |
| 2658 | if self.allow_none and s == "None": |
no test coverage detected