Use assignment expressions 30 (#58714)

This commit is contained in:
Marc Mueller 2021-10-30 16:33:42 +02:00 committed by GitHub
parent 7063c05127
commit 84618fa831
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 33 additions and 77 deletions

View file

@ -75,8 +75,7 @@ def ensure_pin_format(pin, allow_insecure_setup_codes=None):
If incorrect code is entered, an exception is raised.
"""
match = PIN_FORMAT.search(pin.strip())
if not match:
if not (match := PIN_FORMAT.search(pin.strip())):
raise aiohomekit.exceptions.MalformedPinError(f"Invalid PIN code f{pin}")
pin_without_dashes = "".join(match.groups())
if not allow_insecure_setup_codes and pin_without_dashes in INSECURE_CODES: