-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak type error handling #12
Conversation
abc6f48
to
d55babe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts and suggestions, no blockers. 👍
.pre-commit-config.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought (out of scope): Are we running pre-commit in CI? If not, perhaps we should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, I hadn't thought of that as being standard practice, but maybe it's a good idea. Do we do that on kraken-core?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We are running the same things that precommit does in CI, though, such as linting and formatting checks.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not uncommon to use pre-commit to do the running of those tools, especially in smaller projects.
KC does not do that.
tests/test_python_interface.py
Outdated
( | ||
object(), | ||
34.3, | ||
1_000_000_000_000, # Larger than unsigned long integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: It looks like ints are unacceptable, regardless of if they're in range. Perhaps we should add that to the test too.
(Perhaps it's just not clear to me why we're testing out-of-range values in this way.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's a good point - the out of range thing is only relevant for the variable values. I'll change it.
tests/test_python_interface.py
Outdated
34.3, | ||
1_000_000_000_000, # Larger than unsigned long integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the comment above, it might be worth accounting for ints that are in range here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's covered by the test below, test_selector
.
But I just realised that this should say 'signed', not 'unsigned', so thanks for drawing my attention to it!
if !python_key.is_instance_of::<PyString>() { | ||
return Err(PyTypeError::new_err(format!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought (out of scope): I'm beginning to wonder if we might be able to represent this whole for-loop-context with a match
statement? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there's certainly room for improvement! I'm still a noob at Rust. 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too :D
In a moment we will change the behaviour, and it'll be easier to see from one test.
d55babe
to
cc4be14
Compare
Tweaks the way we handle problematic types passed to
bundle.get_translation
, relating to fluent variables.TypeError
. Variable keys should be hardcoded in an application, so it's helpful to see it crash.