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

chore: Bump pydantic to ^2.4.2 [TCTC-7241] #1272

Merged
merged 36 commits into from
Dec 15, 2023
Merged

Conversation

lukapeschke
Copy link
Contributor

No description provided.

@lukapeschke lukapeschke added the dependencies Pull requests that update a dependency file label Sep 11, 2023
@lukapeschke lukapeschke self-assigned this Sep 11, 2023
Copy link
Member

@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

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

Sinon top 👍 Content du refacto pour le kwarg dans __init_subclass__
C'est encore plus clean

@@ -65,7 +65,7 @@ def test_get_form(mocker, connector, create_datasource):
)
form = create_datasource.get_form(connector, {})
assert form['properties']['parameters']['description'] == 'Services documentation: <br> coucou'
assert form['definitions']['method']['enum'][0] == 'fake_func'
assert form['$defs']['method']['const'] == 'fake_func'
Copy link
Member

Choose a reason for hiding this comment

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

J'aurais proposé de changer DEFAULT_REF_TEMPLATE pour changer le moins de tests possibles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je viens de tester avec ref_template='#/definitions/{model}', et les definitions restent malgré tout dans la clé $defs. Seule leur référence change. Exemple:

from enum import StrEnum
import json

from pydantic import BaseModel


class E(StrEnum):
    one = "one"
    two = "two"


class A(BaseModel):
    e: E


print(json.dumps(A.model_json_schema(), indent=2))
print(json.dumps(A.model_json_schema(ref_template="#/definitions/{model}"), indent=2))

Donne

{
  "$defs": {
    "E": {
      "enum": [
        "one",
        "two"
      ],
      "title": "E",
      "type": "string"
    }
  },
  "properties": {
    "e": {
      "$ref": "#/$defs/E"
    }
  },
  "required": [
    "e"
  ],
  "title": "A",
  "type": "object"
}
{
  "$defs": {
    "E": {
      "enum": [
        "one",
        "two"
      ],
      "title": "E",
      "type": "string"
    }
  },
  "properties": {
    "e": {
      "$ref": "#/definitions/E"
    }
  },
  "required": [
    "e"
  ],
  "title": "A",
  "type": "object"
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je viens de tester avec ref_template='#/definitions/{model}', et les definitions restent malgré tout dans la clé $defs. Seule leur référence change. Exemple:

from enum import StrEnum
import json

from pydantic import BaseModel


class E(StrEnum):
    one = "one"
    two = "two"


class A(BaseModel):
    e: E


print(json.dumps(A.model_json_schema(), indent=2))
print(json.dumps(A.model_json_schema(ref_template="#/definitions/{model}"), indent=2))

Donne

{
  "$defs": {
    "E": {
      "enum": [
        "one",
        "two"
      ],
      "title": "E",
      "type": "string"
    }
  },
  "properties": {
    "e": {
      "$ref": "#/$defs/E"
    }
  },
  "required": [
    "e"
  ],
  "title": "A",
  "type": "object"
}
{
  "$defs": {
    "E": {
      "enum": [
        "one",
        "two"
      ],
      "title": "E",
      "type": "string"
    }
  },
  "properties": {
    "e": {
      "$ref": "#/definitions/E"
    }
  },
  "required": [
    "e"
  ],
  "title": "A",
  "type": "object"
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je viens de tester avec ref_template='#/definitions/{model}', et les definitions restent malgré tout dans la clé $defs. Seule leur référence change. Exemple:

from enum import StrEnum
import json

from pydantic import BaseModel


class E(StrEnum):
    one = "one"
    two = "two"


class A(BaseModel):
    e: E


print(json.dumps(A.model_json_schema(), indent=2))
print(json.dumps(A.model_json_schema(ref_template="#/definitions/{model}"), indent=2))

Donne

{
  "$defs": {
    "E": {
      "enum": [
        "one",
        "two"
      ],
      "title": "E",
      "type": "string"
    }
  },
  "properties": {
    "e": {
      "$ref": "#/$defs/E"
    }
  },
  "required": [
    "e"
  ],
  "title": "A",
  "type": "object"
}
{
  "$defs": {
    "E": {
      "enum": [
        "one",
        "two"
      ],
      "title": "E",
      "type": "string"
    }
  },
  "properties": {
    "e": {
      "$ref": "#/definitions/E"
    }
  },
  "required": [
    "e"
  ],
  "title": "A",
  "type": "object"
}

Copy link
Member

@PrettyWood PrettyWood Sep 14, 2023

Choose a reason for hiding this comment

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

c'est pas un bug ? 🤔
A priori non

README.md Outdated
@@ -155,10 +155,8 @@ class MyTypeDataSource(ToucanDataSource):
query: str


class MyTypeConnector(ToucanConnector):
class MyTypeConnector(ToucanConnector,data_source_model=MyTypeDataSource):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class MyTypeConnector(ToucanConnector,data_source_model=MyTypeDataSource):
class MyTypeConnector(ToucanConnector, data_source_model=MyTypeDataSource):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pyproject.toml Outdated
@@ -23,7 +23,7 @@ Authlib = "^1.0.1"
cached-property = "^1.5.2"
Jinja2 = "^3.0.3"
jq = "^1.2.2"
pydantic = "^1.9.1"
pydantic = "^2.3.0"
Copy link
Member

Choose a reason for hiding this comment

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

ptet qu'on peut deja mettre la 2.4.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests/google_sheets_2/test_google_sheets_2.py Outdated Show resolved Hide resolved
class GoogleBigQueryConnector(ToucanConnector, DiscoverableConnector):
class GoogleBigQueryConnector(
ToucanConnector, DiscoverableConnector, data_source_model=GoogleBigQueryDataSource
):
data_source_model: GoogleBigQueryDataSource
Copy link
Member

Choose a reason for hiding this comment

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

a virer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Luka Peschke <[email protected]>
Signed-off-by: Luka Peschke <[email protected]>
Signed-off-by: Luka Peschke <[email protected]>
@lukapeschke lukapeschke changed the title chore: Bump pydantic to ^2.3.0 chore: Bump pydantic to ^2.4.2 [TCTC-7241] Nov 22, 2023
@lukapeschke lukapeschke merged commit f05811f into master Dec 15, 2023
3 checks passed
@lukapeschke lukapeschke deleted the upgrade-pydantic branch December 15, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file 💀 DO NOT MERGE ! 💀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants