Skip to content

Conversation

@nickanderson
Copy link
Member

@nickanderson nickanderson commented Nov 11, 2025

I wasn't looking at the ticket prior to implementation, likely missing things.

Ticket: CFE-3635

@olehermanse olehermanse self-requested a review November 12, 2025 19:50
@olehermanse olehermanse requested a review from larsewi January 5, 2026 13:53
Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

GJ 🚀

I wasn't looking at the ticket prior to implementation, likely missing things.

Ticket: CFE-3653
- Improve state validation error message.
- Move validation to attribute validators.
- Simplify state checking logic.
- Use info logging for repairs.
- Remove redundant try/except blocks.
- Add test and documentation files.
Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

Some comments 😉

Added ability to reset/default a module as well as specify "default" for the
profile or stream.
@nickanderson nickanderson requested a review from larsewi January 22, 2026 20:50
@nickanderson
Copy link
Member Author

ok @larsewi 🫣

@nickanderson nickanderson changed the title CFE-3653: Prototyped dnf_appstream custom promise type CFE-3635: Prototyped dnf_appstream custom promise type Jan 22, 2026
Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

Getting closer 😉 Please format with black and run a linter like pyright or similar

profile = attributes.get("profile", None)

try:
from libdnf.module import ModulePackageContainer
Copy link
Contributor

Choose a reason for hiding this comment

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

libdnf.module.ModulePackageContainer imported but never used

base.read_all_repos()

# Fill the sack (package database)
base.fill_sack(load_system_repo='auto')
Copy link
Contributor

Choose a reason for hiding this comment

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

Assigning string to an argument of type bool

base.fill_sack(load_system_repo='auto')

# Get ModulePackageContainer from sack
if hasattr(base.sack, '_moduleContainer'):
Copy link
Contributor

@larsewi larsewi Jan 23, 2026

Choose a reason for hiding this comment

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

Suggested change
if hasattr(base.sack, '_moduleContainer'):
if hasattr(base.sack, '_moduleContainer'):
assert base.sack is not None

if you are certain that it is not None. Otherwise, check for None

f"dot, and dash characters are allowed."
)

def validate_promise(self, promiser, attributes, meta):
Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter 4 name mismatch: base parameter is named "metadata", override parameter is named "meta".

Suggested change
def validate_promise(self, promiser, attributes, meta):
def validate_promise(self, promiser, attributes, metadata):


self._validate_module_name(promiser)

def evaluate_promise(self, promiser, attributes, meta):
Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter 4 name mismatch: base parameter is named "metadata", override parameter is named "meta".

Suggested change
def evaluate_promise(self, promiser, attributes, meta):
def validate_promise(self, promiser, attributes, metadata):

else:
self.log_error(f"Failed to enable module {module_name}:{target_stream}")
return Result.NOT_KEPT
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

What exception do you expect here? Please don't handle all exceptions.

else:
self.log_error(f"Failed to disable module {module_name}")
return Result.NOT_KEPT
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

What exception do you expect here? Please don't handle all exceptions.

Comment on lines +316 to +319
if not profile:
profile = self._get_default_profile(mpc, module_name, stream)

if not profile:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if not profile:
profile = self._get_default_profile(mpc, module_name, stream)
if not profile:
if not profile:
profile = self._get_default_profile(mpc, module_name, stream)

try:
base.remove(pkg)
# dnf.exceptions.Error catches package not installed, etc.
except dnf.exceptions.Error as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

exceptions is not a known attribute of module dnf

# state => "default";
# }

import dnf
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing import

Suggested change
import dnf
import dnf
import dnf.exceptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants