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

support python 3.11 #1103

Merged
merged 5 commits into from
Oct 31, 2022
Merged

support python 3.11 #1103

merged 5 commits into from
Oct 31, 2022

Conversation

oroulet
Copy link
Member

@oroulet oroulet commented Oct 28, 2022

No description provided.

@oroulet
Copy link
Member Author

oroulet commented Oct 28, 2022

@schroeder- any ideas what is happening here?
I fixed an obvious issue that shoul dave failed before 3.11 but now that error is a bit strange. I have no ideas how that code could have worked before. Maybe they added some check at dataclass definition. it would require to add reordering of dependencies when importting and I really do not feel like doing that...

@oroulet
Copy link
Member Author

oroulet commented Oct 28, 2022

I think I will jsut disable that test for now

@@ -157,7 +157,7 @@ def get_default_value(uatype, enums=None):
# We have an enum, try to initilize it correctly
val = list(getattr(ua, uatype).__members__)[0]
return f"ua.{uatype}.{val}"
return f"ua.{uatype}()"
return f"field(default_factory=ua.{uatype})"
Copy link
Contributor

Choose a reason for hiding this comment

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

This changes breaks the old struct code.
The problem is that the old code registers the variables to ua namespace after executing the codes in another step.
This would require some reworking of the old struct code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not understand that one. That change should only change the way the dataclass is initiliazed. How does it change the registratoin to the ua namespace?

Copy link
Contributor

Choose a reason for hiding this comment

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

The old code first creates all classes and after that they are registered to the ua namespace. So if they are used in the default_factory that will fail.

Copy link
Contributor

@schroeder- schroeder- Oct 30, 2022

Choose a reason for hiding this comment

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

If you change the line back the test will pass. But the 1.04 will fail ...

Copy link
Member Author

Choose a reason for hiding this comment

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

arrgg. OK now I remember I found out that yesterday, but then you cannot simply register because you also need to reorder dependencies and that is not done in that code... Not sure what to do. either we do not support 3.11 or we break old structure support. Or we need someone to implement that reodering because I really do not have time

@schroeder-
Copy link
Contributor

You can merge and I try the change the old struct code after that.

@oroulet
Copy link
Member Author

oroulet commented Oct 30, 2022

You can merge and I try the change the old struct code after that.

but currently I have 0 idea why the old code is broken

@oroulet
Copy link
Member Author

oroulet commented Oct 30, 2022

OK. I have one absolutely horrible bypass:
return f"field(default_factory=lambda :ua.{uatype})"
that makes everything work. probably by bypassing some new python 3.11 checks

@oroulet
Copy link
Member Author

oroulet commented Oct 30, 2022

let's try that one

@oroulet oroulet requested a review from schroeder- October 31, 2022 05:56
@schroeder-
Copy link
Contributor

I think that hack is actually the best way without reordering the whole old struct code.

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.

2 participants