>>> _isint("123") True >>> _isint("123.45") False
(string, inttype=int)
| 953 | |
| 954 | |
| 955 | def _isint(string, inttype=int): |
| 956 | """ |
| 957 | >>> _isint("123") |
| 958 | True |
| 959 | >>> _isint("123.45") |
| 960 | False |
| 961 | """ |
| 962 | return ( |
| 963 | type(string) is inttype |
| 964 | or ( |
| 965 | (hasattr(string, "is_integer") or hasattr(string, "__array__")) |
| 966 | and str(type(string)).startswith("<class 'numpy.int") |
| 967 | ) # numpy.int64 and similar |
| 968 | or ( |
| 969 | isinstance(string, (bytes, str)) and _isconvertible(inttype, string) |
| 970 | ) # integer as string |
| 971 | ) |
| 972 | |
| 973 | |
| 974 | def _isbool(string): |
no test coverage detected