TwistedSim
TwistedSim

Reputation: 2030

PyCharm typing warning with chained comparison

With the following code snippet in PyCharm:

print(1.0 < 2.0 < 3.0)

I received the following warning over the 3.0:

Expected type int, got float instead.

Why the expected type given by PyCharm is int? Is that a typing error from PyCharm or is it something fundamental about the chain comparison?

The following code do not raise any PyCharm warning:

print(1.0 < 2.0 < 3)
print(1.0 < 2 < 3)

Upvotes: 2

Views: 79

Answers (1)

TwistedSim
TwistedSim

Reputation: 2030

I found the issue in the PyCharm bug tracker thanks to @AKX. It should be fix by now, I'll update my PyCharm version to 2018.

Follow-up: It's fixed in 2018.

Upvotes: 3

Related Questions