Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

pj_poi: Fix 'get_lodging_stars' on null category #272

Merged
merged 1 commit into from
Sep 23, 2021
Merged

Conversation

amatissart
Copy link
Contributor

if match := self.HOTEL_STARS_REGEX.match(acc.category):

would fail if acc.category is None.

Comment on lines +578 to +580
if acc.category:
if match := self.HOTEL_STARS_REGEX.match(acc.category):
return float(match.group("rating"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if acc.category:
if match := self.HOTEL_STARS_REGEX.match(acc.category):
return float(match.group("rating"))
if acc.category and (match := self.HOTEL_STARS_REGEX.match(acc.category)):
return float(match.group("rating"))

We could also have done that, but this := operator quickly makes things weird and harder to read, I'm not sure what to think of it ^^'

@amatissart amatissart merged commit c064104 into master Sep 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants