#55 Refactor PkgHelper to avoid modifying global DNF package behavior
Closed: Fixed by lruzicka. Opened by lruzicka.

Problem

Currently, fedora-easy-karma uses a PkgHelper class that modifies the global behavior of the dnf.package.Package class by dynamically injecting a __getitem__ method:

dnf.package.Package.__getitem__ = lambda self, key: getattr(self, key)

This practice is dangerous and can lead to unexpected side effects elsewhere in the application or any libraries using DNF.

Possible solution

Refactor PkgHelper into a new design that wraps the dnf.package.Package object in a safe local wrapper class.

The wrapper should:

  • provide the same convenience (pkg["name"] and pkg.name both work),

  • avoid modifying any DNF internal objects globally.

PackageWrapper will be a small wrapper class that proxies both attribute access and index access to the underlying dnf.package.Package instance.

Packages: the PkgHelper will be renamed so that the name tells more about what we can expext from this class. It will stay the same, but will use the PackageWrapper to enable the previous functionality.


Metadata Update from @lruzicka:
- Custom field story_points adjusted to 2

Commit 8ce99dce fixes this issue

This issue has been migrated to Fedora Forge:
https://forge.fedoraproject.org/quality/fedora-easy-karma/issues/55

Please continue any further discussion there.

Metadata
Related Pull Requests