metomi / isodatetime

:date: :watch: Python ISO 8601 date time parser and data model/manipulation utilities
GNU Lesser General Public License v3.0
37 stars 20 forks source link

Syntax Warning #175

Closed MauriceBrg closed 4 years ago

MauriceBrg commented 4 years ago

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 4 years ago

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 4 years ago

(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/)

MauriceBrg commented 4 years ago

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 :-)