Skip to content

Commit eefcb2f

Browse files
committed
[MIG] pydantic: Migration to 15.0
1 parent fe7c721 commit eefcb2f

7 files changed

Lines changed: 26 additions & 60 deletions

File tree

pydantic/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Pydantic
1414
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1515
:alt: License: LGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
17-
:target: https://github.com/OCA/rest-framework/tree/14.0/pydantic
17+
:target: https://github.com/OCA/rest-framework/tree/15.0/pydantic
1818
:alt: OCA/rest-framework
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/rest-framework-14-0/rest-framework-14-0-pydantic
20+
:target: https://translation.odoo-community.org/projects/rest-framework-15-0/rest-framework-15-0-pydantic
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/271/14.0
23+
:target: https://runbot.odoo-community.org/runbot/271/15.0
2424
:alt: Try me on Runbot
2525

2626
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -168,7 +168,7 @@ Bug Tracker
168168
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
169169
In case of trouble, please check there if your issue has already been reported.
170170
If you spotted it first, help us smashing it by providing a detailed and welcomed
171-
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20pydantic%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
171+
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20pydantic%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
172172

173173
Do not contact contributors directly about support or help with technical issues.
174174

@@ -206,6 +206,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
206206

207207
|maintainer-lmignon|
208208

209-
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/14.0/pydantic>`_ project on GitHub.
209+
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/15.0/pydantic>`_ project on GitHub.
210210

211211
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

pydantic/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Pydantic",
66
"summary": """
77
Enhance pydantic to allow model extension""",
8-
"version": "14.0.1.0.0",
8+
"version": "15.0.1.0.0",
99
"development_status": "Beta",
1010
"license": "LGPL-3",
1111
"maintainers": ["lmignon"],

pydantic/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def __new__(cls, *args, **kwargs):
164164
return super().__new__(cls)
165165
return cls._get_assembled_cls()(*args, **kwargs)
166166

167+
# pylint: disable=W8110
167168
@classmethod
168169
def update_forward_refs(cls, **localns: Any) -> None:
169170
for b in cls.__bases__:

pydantic/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PydanticClassDefsRegistry(dict):
3838

3939

4040
class PydanticClassesDatabases(dict):
41-
""" Holds a registry of pydantic classes for each database """
41+
"""Holds a registry of pydantic classes for each database"""
4242

4343

4444
class PydanticClassesRegistry(object):

pydantic/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">Pydantic</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rest-framework/tree/14.0/pydantic"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rest-framework-14-0/rest-framework-14-0-pydantic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/271/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
370+
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rest-framework/tree/15.0/pydantic"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rest-framework-15-0/rest-framework-15-0-pydantic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/271/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
371371
<p>This addon allows you to define inheritable <a class="reference external" href="https://pydantic-docs.helpmanual.io/">Pydantic classes</a>.</p>
372372
<p><strong>Table of contents</strong></p>
373373
<div class="contents local topic" id="contents">
@@ -501,7 +501,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
501501
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rest-framework/issues">GitHub Issues</a>.
502502
In case of trouble, please check there if your issue has already been reported.
503503
If you spotted it first, help us smashing it by providing a detailed and welcomed
504-
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20pydantic%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
504+
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20pydantic%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
505505
<p>Do not contact contributors directly about support or help with technical issues.</p>
506506
</div>
507507
<div class="section" id="credits">
@@ -527,7 +527,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
527527
promote its widespread use.</p>
528528
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
529529
<p><a class="reference external" href="https://github.com/lmignon"><img alt="lmignon" src="https://github.com/lmignon.png?size=40px" /></a></p>
530-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/14.0/pydantic">OCA/rest-framework</a> project on GitHub.</p>
530+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/15.0/pydantic">OCA/rest-framework</a> project on GitHub.</p>
531531
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
532532
</div>
533533
</div>

pydantic/tests/common.py

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class TransactionPydanticCase(common.TransactionCase, PydanticMixin):
6464

6565
@classmethod
6666
def setUpClass(cls):
67-
super(TransactionPydanticCase, cls).setUpClass()
67+
super().setUpClass()
6868
cls.setUpPydantic()
6969

7070
# pylint: disable=W8106
@@ -75,30 +75,8 @@ def setUp(self):
7575
PydanticMixin.setUp(self)
7676

7777

78-
class SavepointPydanticCase(common.SavepointCase, PydanticMixin):
79-
"""A SavepointCase that loads all the pydantic classes
80-
81-
It is used like an usual Odoo's SavepointCase, but it ensures
82-
that all the pydantic classes of the current addon and its dependencies
83-
are loaded.
84-
85-
"""
86-
87-
@classmethod
88-
def setUpClass(cls):
89-
super(SavepointPydanticCase, cls).setUpClass()
90-
cls.setUpPydantic()
91-
92-
# pylint: disable=W8106
93-
def setUp(self):
94-
# resolve an inheritance issue (common.SavepointCase does not call
95-
# super)
96-
common.SavepointCase.setUp(self)
97-
PydanticMixin.setUp(self)
98-
99-
10078
class PydanticRegistryCase(
101-
common.TreeCase, common.MetaCase("DummyCase", (object,), {})
79+
common.BaseCase, common.MetaCase("DummyCase", (object,), {})
10280
):
10381
"""This test case can be used as a base for writings tests on pydantic classes
10482
@@ -107,10 +85,9 @@ class PydanticRegistryCase(
10785
or not, or when you want to create additional pydantic classes in your tests.
10886
10987
If you only want to *use* the pydantic classes of the tested addon in your tests,
110-
then consider using one of:
88+
then consider using:
11189
11290
* :class:`TransactionPydanticCase`
113-
* :class:`SavepointPydanticCase`
11491
11592
This test case creates a special
11693
:class:`odoo.addons.pydantic.registry.PydanticClassesRegistry` for the purpose of
@@ -132,7 +109,7 @@ class PydanticRegistryCase(
132109
"""
133110

134111
def setUp(self):
135-
super(PydanticRegistryCase, self).setUp()
112+
super().setUp()
136113

137114
# keep the original classes registered by the annotation
138115
# so we'll restore them at the end of the tests, it avoid
@@ -182,7 +159,7 @@ def notready():
182159
odoo_pydantic_registry.reset(token)
183160

184161
def tearDown(self):
185-
super(PydanticRegistryCase, self).tearDown()
162+
super().tearDown()
186163
self.restore_registry()
187164

188165
def _load_module_pydantics(self, module):
@@ -212,30 +189,17 @@ def restore_registry(self):
212189

213190

214191
class TransactionPydanticRegistryCase(common.TransactionCase, PydanticRegistryCase):
215-
""" Adds Odoo Transaction in the base Pydantic TestCase """
192+
"""Adds Odoo Transaction in the base Pydantic TestCase"""
216193

217194
# pylint: disable=W8106
218-
def setUp(self):
195+
@classmethod
196+
def setUpClass(cls):
219197
# resolve an inheritance issue (common.TransactionCase does not use
220198
# super)
221-
common.TransactionCase.setUp(self)
222-
PydanticRegistryCase.setUp(self)
223-
224-
def teardown(self):
225-
common.TransactionCase.tearDown(self)
226-
PydanticRegistryCase.tearDown(self)
227-
228-
229-
class SavepointPydanticRegistryCase(common.SavepointCase, PydanticRegistryCase):
230-
""" Adds Odoo Transaction with Savepoint in the base Pydantic TestCase """
231-
232-
# pylint: disable=W8106
233-
def setUp(self):
234-
# resolve an inheritance issue (common.SavepointCase does not use
235-
# super)
236-
common.SavepointCase.setUp(self)
237-
PydanticRegistryCase.setUp(self)
199+
common.TransactionCase.setUpClass(cls)
200+
PydanticRegistryCase.setUp(cls)
238201

239-
def teardown(self):
240-
common.SavepointCase.tearDown(self)
241-
PydanticRegistryCase.tearDown(self)
202+
@classmethod
203+
def tearDownClass(cls):
204+
common.TransactionCase.tearDownClass(cls)
205+
PydanticRegistryCase.tearDown(cls)

pydantic/tests/test_pydantic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
class TestPydantic(PydanticRegistryCase):
13+
# pylint: disable=W8110
1314
def test_simple_inheritance(self):
1415
class Location(models.BaseModel):
1516
lat = 0.1

0 commit comments

Comments
 (0)