How should I type-hint an integer variable that can also be infinite?
问题 Searching for this topic I came across the following: How to represent integer infinity? I agree with Martijn Peeters that adding a separate special infinity value for int may not be the best of ideas. However, this makes type hinting difficult. Assume the following code: myvar = 10 # type: int myvar = math.inf # <-- raises a typing error because math.inf is a float However, the code behaves everywhere just the way as it should. And my type hinting is correct everywhere else. If I write the