tmt icon indicating copy to clipboard operation
tmt copied to clipboard

Add plugin data instance creation during linting

Open skycastlelily opened this issue 3 months ago • 1 comments

Pull Request Checklist

  • [ ] implement the feature
  • [ ] write the documentation
  • [ ] extend the test coverage
  • [ ] update the specification
  • [ ] adjust plugin docstring
  • [ ] modify the json schema
  • [ ] mention the version
  • [ ] include a release note

skycastlelily avatar Nov 06 '25 14:11 skycastlelily

Please indicate when a PR is based on another one.

sure, and done:)

skycastlelily avatar Nov 12 '25 08:11 skycastlelily

So @skycastlelily what do you think about making this its own lint rule like

class Plan:
    def lint_unique_names(self) -> LinterReturn:
        """
        P0XX: phases must have valid data
        """
        passed = True
        for step in self.steps:
            for phase in step.phases:
                try:
                    # Need to call the property once because it is lazy evaluated otherwise
                    _ = phase.data
                except Exception:
                    passed = False
                    yield LinterOutcome.FAIL, "..."
        if passed:
            yield LinterOutcome.PASS, 'phases have unique names'

LecrisUT avatar Dec 04 '25 15:12 LecrisUT

So @skycastlelily what do you think about making this its own lint rule like

class Plan:
    def lint_unique_names(self) -> LinterReturn:
        """
        P0XX: phases must have valid data
        """
        passed = True
        for step in self.steps:
            for phase in step.phases:
                try:
                    # Need to call the property once because it is lazy evaluated otherwise
                    _ = phase.data
                except Exception:
                    passed = False
                    yield LinterOutcome.FAIL, "..."
        if passed:
            yield LinterOutcome.PASS, 'phases have unique names'

I think it's pretty, actually that is the solution I was thinking to take before I sent this mr, however it does not work, because normalize* functions will not be called by tmt lint.I read your previous comments thoroughly, and spend many time to find a solution in that way, but failed :sweat_smile: ,feel free to take this mr or open a new mr to implement your thoughts, you have my bless :)

skycastlelily avatar Dec 05 '25 10:12 skycastlelily

I think it's pretty, actually that is the solution I was thinking to take before I sent this mr, however it does not work, because normalize* functions will not be called by tmt lint.

That is odd, the snippet does the same .data as your PR here, so it should go through the same logic. I guess I can look more carefully in what is going on there

LecrisUT avatar Dec 05 '25 10:12 LecrisUT

Closing, as #4409 addressed it in a more pretty and clean way:)

skycastlelily avatar Dec 08 '25 10:12 skycastlelily