Skip to content
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

c.info requires native types #2691

Merged
merged 1 commit into from Apr 19, 2024
Merged

c.info requires native types #2691

merged 1 commit into from Apr 19, 2024

Conversation

qt-thomas
Copy link

I caught an untested bug on the straight component: c.info["length"] = length. Pydantic complained that length was not int or float (and it did not coerce it). Instead it was a numpy int which was returned by a rounding function. I fixed with c.info["length"] = float(length).

I assumed this was the right solution as I saw it somewhere else in the codebase. Hope others find this error here. I am pasting the error in case someone might google:

pydantic_core._pydantic_core.ValidationError: 1 validation error for Info
  Value error, Values of the info dict only support int, float, string or tuple.length: 960, <class 'numpy.int64'> [type=value_error, input_value={'length': 960}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.6/v/value_error

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @qt-thomas - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@joamatab joamatab self-requested a review April 19, 2024 00:13
Copy link
Contributor

@joamatab joamatab left a comment

Choose a reason for hiding this comment

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

thank you Thomas!

@joamatab joamatab merged commit 18d05e3 into gdsfactory:main Apr 19, 2024
5 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants