Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for Union[None, List[datetime.datetime]] values when printing user table in weekly mail logs #2378

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

begincalendar
Copy link

Effect

I received the following in my weekly mail log email (Cron root@mail (cd /root/mailinabox && management/daily_tasks.sh)):

Traceback (most recent call last):
  File "/root/mailinabox/management/mail_log.py", line 869, in <module>
    scan_mail_log(env_vars)
  File "/root/mailinabox/management/mail_log.py", line 146, in scan_mail_log
    print_user_table(
  File "/root/mailinabox/management/mail_log.py", line 682, in print_user_table
    if None not in {latest, earliest}:
TypeError: unhashable type: 'list'

Cause

This was overzealous in that it didn't accommodate for the fact that earliest and latest have the type Union[None, List[datetime.dateime]].

I think this PR supersedes #2376.

@kimusan
Copy link
Contributor

kimusan commented Apr 8, 2024

Good solution.

Copy link

@dms00 dms00 left a comment

Choose a reason for hiding this comment

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

Nice fix. Is there a comment we can add to those lines so the linter won't try to change them again in the future?

@dms00
Copy link

dms00 commented Apr 8, 2024

Looks like # noqa PLR6201 should do the trick.

@benschumacher
Copy link
Contributor

I just encountered this issue, as well. Thanks for the fix!

@tricktux tricktux mentioned this pull request May 9, 2024
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.

None yet

4 participants