Skip to content

Reconsider FakeContext usage in infractions code #2571

@wookie184

Description

@wookie184

I think we should consider (probably not in this PR) changing the type hints for any functions that can take a FakeContext, since just Context is misleading and makes it easy to introduce bugs like this.

I think the issue now is that we have 3 context classes: Context, FakeContext and FilterContext that are being used for conversion, and post_infraction takes either Context or FakeContext.

In this particular case, I think it's an instance of FilterContext that's being converted to FakeContext at the level of the InfractionAndNotification.action method .

But I do agree that it might need to be cleaned up.

I'll try to tackle this next.

Originally posted by @shtlrs in #2556 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: filtersRelated to message filters: (antimalware, antispam, filtering, token_remover)a: moderationRelated to community moderation functionality: (moderation, defcon, verification)s: planningDiscussing detailst: enhancementChanges or improvements to existing features

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions