fedora-infra / maubot-pretix-invite

A maubot plugin for inviting event participants from the pretix ticketing platform into a matrix room
MIT License
2 stars 0 forks source link

from collections import Counter #4

Closed HarHarLinks closed 2 weeks ago

HarHarLinks commented 2 weeks ago

https://github.com/MoralCode/maubot-events/blob/7738a7ebe962652b173813da3f626a46be0ac039/event_helper/matrix_utils.py#L52

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/mautrix/client/syncer.py", line 236, in _catch_errors
    await handler(data)
  File "/opt/maubot/maubot/handlers/command.py", line 154, in __call__
    return await self.__mb_func__(self.__bound_instance__, evt, **call_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/plugins/org.fedoraproject.maubot.events-v0.2.0.mbp/event_helper/__init__.py", line 257, in batchinvite
    failed_invites = self.invite_attendees(room_id, data)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/plugins/org.fedoraproject.maubot.events-v0.2.0.mbp/event_helper/__init__.py", line 213, in invite_attendees
    validated_id = validate_matrix_id(matrix_id)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/plugins/org.fedoraproject.maubot.events-v0.2.0.mbp/event_helper/matrix_utils.py", line 52, in validate_matrix_id
    frequency = Counter(possible_matrix_id)
                ^^^^^^^
NameError: name 'Counter' is not defined
MoralCode commented 2 weeks ago

huh this is strange. I saw this with #3 as well where a thing is imported in one of the helper files but the import itself is in __init__.py. it seemed to work when I've been running it in the fedora bot dev environment. has maubot changed how it evaluates imports in more recent versions?

Regardless i made a fix that should address this in 634d5b9f77c15d49c98da3363083acae92ff2c6a on the dev branch (keeping it on a separate branch until I can re-test this in fedoras dev environment and confirm it still works)

HarHarLinks commented 2 weeks ago

i think this might work coincidentally in some python environments, but afaik in python you're supposed to import stuff in the files that use it and not rely on import recursion/transitivity

MoralCode commented 2 weeks ago

i think this might work coincidentally in some python environments, but afaik in python you're supposed to import stuff in the files that use it and not rely on import recursion/transitivity

yeah, thats normally how I do things - keeping the imports in the right file. i think because it happened to still work in fedoras matrix bot dev environment i never saw these errors in testing and therefore never got that reminder that i also needed to move the imports when refactoring things