Skip to content

Conversation

@ialarmedalien
Copy link
Collaborator

Adding a little bit of "insurance" to some slot range functions to ensure that they check the input is the correct type before running off and performing any functions with it.

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.24%. Comparing base (dccdc1f) to head (310f85b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #480      +/-   ##
==========================================
+ Coverage   78.20%   78.24%   +0.03%     
==========================================
  Files          52       52              
  Lines        4525     4533       +8     
  Branches      985      988       +3     
==========================================
+ Hits         3539     3547       +8     
  Misses        768      768              
  Partials      218      218              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@sujaypatil96 sujaypatil96 left a comment

Choose a reason for hiding this comment

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

Adding guardrails to check that the input to some slot details fetcher methods is in fact an object of type SlotDefinition.

Copy link
Contributor

@Silvanoc Silvanoc left a comment

Choose a reason for hiding this comment

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

LGTM, only optional improvement proposal

Comment on lines +1906 to +1909
if not slot or not isinstance(slot, SlotDefinition):
err_msg = "A SlotDefinition must be provided to generate the slot applicable range elements."
raise ValueError(err_msg)

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make sense to have a function for this purpose, since the same validation is being applied in multiple places?

I mean something like

def _validate_slot(slot, err_sfx) -> None:
    if not slot or not isinstance(slot, SlotDefinition):
        raise ValueError(
            f"A SlotDefinition must be provided to generate the {err_sfx}."
        )

BTW you are typically optimizing. I don't get why you use the variable err_msg just for a single use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to resolve comment, and merge, if desired

Copy link
Collaborator Author

@ialarmedalien ialarmedalien Oct 23, 2025

Choose a reason for hiding this comment

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

the err_msg thing is to make the stack trace clearer -- otherwise you get an extra line:

https://docs.astral.sh/ruff/rules/raw-string-in-exception/

You are absolutely right about optimising by creating a generic function. I don't know why I didn't do it - end of the workday, maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, I forgot that recommendation 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm going to investigate options because as soon as I see a verification function like that, I want to make it more generic. I need to get my core work done and then I'll dedicate some time to thinking/researching argument validation.

@ialarmedalien ialarmedalien merged commit db7064f into main Oct 23, 2025
17 checks passed
@ialarmedalien ialarmedalien deleted the schemaview_add_slotdef_check_to_range_fns branch October 23, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants