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

Fix parse_source_type_name #635

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

AdrienVannson
Copy link
Contributor

@AdrienVannson AdrienVannson commented Oct 25, 2024

Summary

Fix #562 , #437

The function parse_source_type_name used to rely on an ad-hoc regex to work. The function failed when the package name had capital letters, since it believed that the package was actually a message.

Now, the function goes through the packages and the messages that are actually defined (no more guess) to find the right one.

I also did some small refactoring of models.py: FieldCompiler used to inherit from MessageCompiler, which made no sense.

The PR still lacks tests and some doc, but since it can take a while to write, I first wanted to have your point of view on this.

NOTE: I completely deleted test_gen_ref_type.py for now, but I plan to replace it once you agree with the content of the PR

Checklist

  • If code changes were made then they have been tested.
  • This PR fixes an issue.

@AdrienVannson AdrienVannson marked this pull request as draft October 25, 2024 13:23
@AdrienVannson AdrienVannson marked this pull request as ready for review October 26, 2024 20:05
Gobot1234
Gobot1234 previously approved these changes Nov 7, 2024
@Gobot1234
Copy link
Collaborator

Ping me once the tests are done

@AdrienVannson
Copy link
Contributor Author

AdrienVannson commented Nov 8, 2024

Hello, I added some documentation, I would say that it is enough. Concerning the tests, I can't just add many simple unit tests as easily as before since the function get_type_reference now also takes a PluginRequestCompiler. However, everything should already be tester in the import_* input tests.

I just need to find out why the tests are failing, this is not normal since I almost changed nothing since the last time, and it works locally

@AdrienVannson
Copy link
Contributor Author

It was just the merge that was not performed correctly, now it should be fine

Comment on lines 603 to 604
py_k_type: Type = None
py_v_type: Type = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change this to pass type checking

Comment on lines -7 to +13
{%- for enum in output_file.enums -%}
{% for _, enum in output_file.enums|dictsort(by="key") %}
"{{ enum.py_name }}",
{%- endfor -%}
{%- for message in output_file.messages -%}
{% for _, message in output_file.messages|dictsort(by="key") %}
"{{ message.py_name }}",
{%- endfor -%}
{%- for service in output_file.services -%}
{% for _, service in output_file.services|dictsort(by="key") %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

How come these are being sorted now?

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.

Invalid code generated when package name contains uppercase letter
2 participants