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

Update pydantic to v2 #496

Open
tokuhirom opened this issue Jul 25, 2023 · 3 comments
Open

Update pydantic to v2 #496

tokuhirom opened this issue Jul 25, 2023 · 3 comments

Comments

@tokuhirom
Copy link
Member

pydantic v2 is not backward compatible.
We need to upgrade it.

@tokuhirom
Copy link
Member Author

We need to rewrite PythonNextgenCustomClientGenerator with the latest style.

diff --git generator/src/main/java/line/bot/generator/PythonNextgenCustomClientGenerator.java generator/src/main/java/line/bot/generator/PythonNextgenCustomClientGenerator.java
index 7d84030..e0e57f1 100644
--- generator/src/main/java/line/bot/generator/PythonNextgenCustomClientGenerator.java
+++ generator/src/main/java/line/bot/generator/PythonNextgenCustomClientGenerator.java
@@ -443,10 +443,10 @@ public class PythonNextgenCustomClientGenerator extends AbstractPythonCodegen im
         if (cp.isArray) {
             String constraints = "";
             if (cp.maxItems != null) {
-                constraints += String.format(Locale.ROOT, ", max_items=%d", cp.maxItems);
+                constraints += String.format(Locale.ROOT, ", max_length=%d", cp.maxItems);
             }
             if (cp.minItems != null) {
-                constraints += String.format(Locale.ROOT, ", min_items=%d", cp.minItems);
+                constraints += String.format(Locale.ROOT, ", min_length=%d", cp.minItems);
             }
             if (cp.getUniqueItems()) {
                 constraints += ", unique_items=True";
@@ -723,10 +723,10 @@ public class PythonNextgenCustomClientGenerator extends AbstractPythonCodegen im
         if (cp.isArray) {
             String constraints = "";
             if (cp.maxItems != null) {
-                constraints += String.format(Locale.ROOT, ", max_items=%d", cp.maxItems);
+                constraints += String.format(Locale.ROOT, ", max_length=%d", cp.maxItems);
             }
             if (cp.minItems != null) {
-                constraints += String.format(Locale.ROOT, ", min_items=%d", cp.minItems);
+                constraints += String.format(Locale.ROOT, ", min_length=%d", cp.minItems);
             }
             if (cp.getUniqueItems()) {
                 constraints += ", unique_items=True";

@tokuhirom
Copy link
Member Author

BTW, there's a remaining error.

================================== short test summary info ===================================
FAILED tests/v3/test_webhook.py::TestWebhookParser::test_parse - TypeError: unhashable type: 'ModelPrivateAttr'
FAILED tests/v3/test_webhook.py::TestWebhookParser::test_parse_webhook_req_without_destination - TypeError: unhashable type: 'ModelPrivateAttr'
FAILED tests/v3/test_webhook.py::TestWebhookHandler::test_handler - TypeError: unhashable type: 'ModelPrivateAttr'

Why it's happened?

@tokuhirom
Copy link
Member Author

https://docs.pydantic.dev/latest/migration/
There's a migration guide.

tokuhirom added a commit to tokuhirom/line-bot-sdk-python that referenced this issue Jul 25, 2023
tokuhirom added a commit that referenced this issue Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant