Skip to content
Snippets Groups Projects
Commit 246f074af9f5 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

update to use latest template, using | instead of Union as allowed by python...

update to use latest template, using | instead of Union as allowed by python 3.10 as it is more readable
parent 39ad132f43ff
No related branches found
No related tags found
1 merge request!26update to use latest template, using | instead of Union as allowed by python...
Changelog Changelog
========= =========
15.0.3.0.0
----------
Update to use python 3.10 idioms.
15.0.2.0.0 15.0.2.0.0
---------- ----------
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"name": "Converter", "name": "Converter",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Convert odoo records to/from plain data structures.", "summary": "Convert odoo records to/from plain data structures.",
"version": "15.0.2.0.0", "version": "15.0.3.0.0",
"category": "Hidden", "category": "Hidden",
"author": "XCG Consulting", "author": "XCG Consulting",
"website": "https://odoo.consulting/", "website": "https://odoo.consulting/",
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
def scan_file(filename, tags) -> tuple[dict[str, tuple[str, int, str]], int]: def scan_file(filename, tags) -> tuple[dict[str, tuple[str, int, str]], int]:
res = {tag: [] for tag in tags} res = {tag: [] for tag in tags}
line_num: int = 0
with open(filename, "r") as f: with open(filename, "r") as f:
for line_num, line in enumerate(f): for line_num, line in enumerate(f):
for tag in tags: for tag in tags:
......
import logging import logging
from collections import OrderedDict from collections import OrderedDict
from collections.abc import Iterable, Mapping from collections.abc import Iterable, Mapping
from typing import Any, Optional, Union from typing import Any, Optional
import jsonschema import jsonschema
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
def get_instance( def get_instance(
self, odoo_env: api.Environment, message_data self, odoo_env: api.Environment, message_data
) -> Optional[Union[models.Model, NewinstanceType]]: ) -> None | models.Model | NewinstanceType:
""":return: an instance linked to the converter, if any""" """:return: an instance linked to the converter, if any"""
if self._get_instance: if self._get_instance:
instance = self._converters[self._get_instance].get_instance( instance = self._converters[self._get_instance].get_instance(
......
[tool.isort] [tool.isort]
py_version = 39 py_version = 310
profile = "black" profile = "black"
known_odoo = ['odoo'] known_odoo = ['odoo']
known_odoo_addons = ['odoo.addons'] known_odoo_addons = ['odoo.addons']
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
] ]
[tool.black] [tool.black]
target = 3.9 target = 3.10
import logging import logging
from typing import Any, Callable, Optional, Union from typing import Any, Callable, Optional
from odoo import api, models from odoo import api, models
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
field_name: str, field_name: str,
model_name: Optional[str], model_name: Optional[str],
converter: Converter, converter: Converter,
filtered: Union[None, str, Callable[[models.Model], bool]] = None, filtered: None | str | Callable[[models.Model], bool] = None,
context: Optional[ContextBuilder] = None, context: Optional[ContextBuilder] = None,
limit: Optional[Any] = None, limit: Optional[Any] = None,
): ):
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
model_name: Optional[str], model_name: Optional[str],
key_converter: Converter, key_converter: Converter,
value_converter: Converter, value_converter: Converter,
filtered: Union[None, str, Callable[[models.Model], bool]] = None, filtered: None | str | Callable[[models.Model], bool] = None,
context: Optional[ContextBuilder] = None, context: Optional[ContextBuilder] = None,
): ):
""" """
......
from typing import Any, Optional, Union from typing import Any, Optional
from odoo import models from odoo import models
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
def get_instance( def get_instance(
self, odoo_env, message_data self, odoo_env, message_data
) -> Optional[Union[models.Model, NewinstanceType]]: ) -> None | models.Model | NewinstanceType:
return odoo_env.ref( return odoo_env.ref(
".".join([self._module, message_data]), raise_if_not_found=False ".".join([self._module, message_data]), raise_if_not_found=False
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment