Skip to content

Remove is_item_relevant flawed abstract method from Applier abstract class and convert it to protocol #410

@nfx

Description

@nfx

is_item_relevant is causing double deserialization of raw permissions state and a more complicated than necessary class structure, increasing coupling as well. Applier has to become a proper typing.Protocol and have only abstract methods, without the need of implementations to inherit from the class.

Example:

    def is_item_relevant(self, item: Permissions, migration_state: GroupMigrationState) -> bool:
        return True

    def _noop(self):
        pass

    def _get_apply_task(self, item: Permissions, migration_state: GroupMigrationState,
                        destination: Destination) -> partial:
        grant = Grant(**json.loads(item.raw))
        group_info = migration_state.get_by_workspace_group_name(grant.principal)
        if group_info is None:
            # technically, we should be able just to `return self._noop`
            return partial(self._noop)
        ...
        return partial(...)

Metadata

Metadata

Assignees

Labels

migrate/groupsCorresponds to Migrate Groups Step of go/uc/upgradetech debtchores and design flaws

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions