metomi/isodatetime

Syntax Warning

MauriceBrg opened this issue · 3 comments

Hey!

I'm using v1!2.0.2 in an AWS Lambda Function (Python 3.8) and it's showing me a SyntaxWarning:

metomi/isodatetime/data.py:2030: SyntaxWarning: "is" with a literal. Did you mean "=="?
if year is not None and (year is "leap" or get_is_leap_year(year)):

In the current code this has moved a few lines down: link

Is this something worth investigating?

Best regards and thanks for the cool library

Maurice

kinow commented

Looks like a bug, I think the first is is OK, but the second year is "lea" needs to use ==? (cc @MetRonnie ) I wonder if mypy or some other linter/parser would have found this issue too.

Good catch @MauriceBrg ! Thanks for reporting.

kinow commented

(also appears that this SyntaxWarning started with Python 3.8+ https://adamj.eu/tech/2020/01/21/why-does-python-3-8-syntaxwarning-for-is-literal/)

Looks like a bug, I think the first is is OK, but the second year is "lea" needs to use ==? (cc @MetRonnie ) I wonder if mypy or some other linter/parser would have found this issue too.

That's how I'd change it as well - thanks for responding so quickly :-)