Skip to content

Fix SyntaxError in async_get_config (except TypeError, ValueError) - #64

Open
ottes wants to merge 1 commit into
iamkarlson:mainfrom
ottes:fix/grocy-data-except-syntaxerror
Open

ottes wants to merge 1 commit into
iamkarlson:mainfrom
ottes:fix/grocy-data-except-syntaxerror

Conversation

@ottes

@ottes ottes commented Aug 31, 2026

Copy link
Copy Markdown

Summary

custom_components/grocy/grocy_data.py line 129 uses Python 2 exception syntax:

except TypeError, ValueError:

This is invalid in Python 3 and raises a SyntaxError when the module is compiled/imported:

  File ".../grocy_data.py", line 129
    except TypeError, ValueError:
           ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized

Because this is a module-level compile error, it breaks the import of grocy_data.py entirely, which breaks setup of the whole Grocy integration as soon as Home Assistant (re)loads it - not just the STOCK_DUE_SOON_DAYS code path this except belongs to.

This looks like it was introduced together with the STOCK_DUE_SOON_DAYS / stock_due_soon_days lowercase-fallback handling in async_get_config (related to #44 / #45).

Fix

Parenthesize the exception tuple, as required by Python 3:

except (TypeError, ValueError):

Testing

  • python3 -c "import ast; ast.parse(open('custom_components/grocy/grocy_data.py').read())" now succeeds (previously raised the SyntaxError above).
  • One-line change, no behavior change beyond fixing the crash.

except TypeError, ValueError: is Python 2 syntax and raises a
SyntaxError in Python 3 at import time, breaking the whole
grocy_data module (and therefore the entire integration) as soon
as it is (re)loaded. Introduced alongside the STOCK_DUE_SOON_DAYS
lowercase-fallback handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant