[FIX] core, base: leftover deprecation warnings

* from collections import <ABC> is deprecated, unclear why the
  deprecation warning didn't appear before (possibly only appears in
  3.7/3.8?) either way `collections.abc` should be 3.3+ so switch
  everything to it.
* add some more ignores on third-party packages deprecation
  warnings (meh)
* while at it, mitigate generation of non-breaking space on some
  versions of Babel (in the french locale used by our tests anyway)

closes odoo/odoo#47581

Related: odoo/enterprise#9214
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2020-03-19 09:32:21 +00:00
parent 41822a5022
commit fe376d50d0
8 changed files with 56 additions and 55 deletions
+5 -4
View File
@@ -1,18 +1,19 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
import dateutil
import itertools
import logging
import re
import time
from ast import literal_eval
from collections import defaultdict, Mapping
from collections import defaultdict
from collections.abc import Mapping
from operator import itemgetter
from odoo import api, fields, models, SUPERUSER_ID, tools, _
import dateutil
from odoo import api, fields, models, tools, _
from odoo.exceptions import AccessError, UserError, ValidationError
from odoo.modules.registry import Registry
from odoo.osv import expression
from odoo.tools import pycompat, unique
from odoo.tools.safe_eval import safe_eval
+4 -8
View File
@@ -5,7 +5,8 @@ import os.path
import re
import traceback
from collections import OrderedDict, Sized, Mapping
from collections import OrderedDict
from collections.abc import Sized, Mapping
from functools import reduce
from itertools import tee, count
from textwrap import dedent
@@ -18,13 +19,8 @@ from werkzeug.utils import escape as _escape
from odoo.tools import pycompat, freehash
try:
import builtins
builtin_defaults = {name: getattr(builtins, name) for name in dir(builtins)}
except ImportError:
# pylint: disable=bad-python3-import
import __builtin__
builtin_defaults = {name: getattr(__builtin__, name) for name in dir(__builtin__)}
import builtins
builtin_defaults = {name: getattr(builtins, name) for name in dir(builtins)}
try:
import astor
@@ -3,6 +3,7 @@
import base64
import datetime
import os
import re
from odoo.tests import common
from odoo.tools import html_escape as e
@@ -37,7 +38,14 @@ class TestExport(common.TransactionCase):
def converter(value, options=None, context=None):
context = context or {}
record = self.Model.with_context(context).new({name: value})
return model.with_context(context).record_to_html(record, name, options or {})
# normalise non-newline spaces: some versions of babel use regular
# spaces while others use non-break space when formatting timedeltas
# to the french locale
return re.sub(
r'[^\S\n\r]', # no \p{Zs}
' ',
model.with_context(context).record_to_html(record, name, options or {})
)
return converter
+5 -6
View File
@@ -15,20 +15,19 @@ __all__ = [
]
import logging
from collections import defaultdict, Mapping
from collections import defaultdict
from collections.abc import Mapping
from contextlib import contextmanager
from copy import deepcopy
from inspect import signature
from pprint import pformat
from weakref import WeakSet
from decorator import decorate, decorator
from decorator import decorate
from werkzeug.local import Local, release_local
import odoo
from .exceptions import CacheMiss
from .tools import frozendict, classproperty, lazy_property, StackMap
from .tools.translate import _
from odoo.tools import frozendict, classproperty, lazy_property, StackMap
from odoo.exceptions import CacheMiss
_logger = logging.getLogger(__name__)
+2 -1
View File
@@ -34,7 +34,8 @@ import operator
import pytz
import re
import uuid
from collections import defaultdict, MutableMapping, OrderedDict
from collections import defaultdict, OrderedDict
from collections.abc import MutableMapping
from contextlib import closing
from inspect import getmembers, currentframe
from operator import attrgetter, itemgetter
+2 -1
View File
@@ -4,7 +4,8 @@
""" Models registries.
"""
from collections import Mapping, defaultdict, deque
from collections import defaultdict, deque
from collections.abc import Mapping
from contextlib import closing, contextmanager
from functools import partial
from operator import attrgetter
+8 -4
View File
@@ -138,10 +138,14 @@ def init_logger():
# ignore deprecation warnings from invalid escape (there's a ton and it's
# pretty likely a super low-value signal)
warnings.filterwarnings('ignore', r'^invalid escape sequence \\.', category=DeprecationWarning)
# ignore warning from older setuptools version using imp
warnings.filterwarnings('ignore', category=DeprecationWarning, module='setuptools.depends')
# ignore warning from zeep using defusedxml.lxml
warnings.filterwarnings('ignore', category=DeprecationWarning, module='zeep.loader')
# ignore a bunch of warnings we can't really fix ourselves
for module in [
'setuptools.depends',# older setuptools version using imp
'zeep.loader',# zeep using defusedxml.lxml
'reportlab.lib.rl_safe_eval',# reportlab importing ABC from collections
'xlrd/xlsx',# xlrd mischecks iter() on trees or something so calls deprecated getiterator() instead of iter()
]:
warnings.filterwarnings('ignore', category=DeprecationWarning, module=module)
from .tools.translate import resetlocale
resetlocale()
+21 -30
View File
@@ -5,54 +5,47 @@
"""
Miscellaneous tools used by OpenERP.
"""
from functools import wraps
import babel
import babel.dates
from contextlib import contextmanager
import cProfile
import collections
import datetime
import math
import subprocess
import io
import os
import collections
import passlib.utils
import pickle as pickle_
import pytz
import re
import socket
import subprocess
import sys
import threading
import time
import traceback
import types
import unicodedata
import werkzeug.utils
import zipfile
from collections import defaultdict, Iterable, Mapping, MutableMapping, MutableSet, OrderedDict
from collections import defaultdict, OrderedDict
from collections.abc import Iterable, Mapping, MutableMapping, MutableSet
from contextlib import contextmanager
from difflib import HtmlDiff
from itertools import islice, groupby as itergroupby, repeat
from lxml import etree
from .which import which
import traceback
from functools import wraps
from itertools import islice, groupby as itergroupby
from operator import itemgetter
try:
# pylint: disable=bad-python3-import
import cProfile
except ImportError:
import profile as cProfile
from .config import config
from .cache import *
from .parse_version import parse_version
from . import pycompat
import babel
import babel.dates
import passlib.utils
import pytz
import werkzeug.utils
from lxml import etree
import odoo
import odoo.addons
# get_encodings, ustr and exception_to_unicode were originally from tools.misc.
# There are moved to loglevels until we refactor tools.
from odoo.loglevels import get_encodings, ustr, exception_to_unicode # noqa
from . import pycompat
from .cache import *
from .config import config
from .parse_version import parse_version
from .which import which
_logger = logging.getLogger(__name__)
@@ -158,7 +151,6 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False):
@return fileobject if pathinfo is False else (fileobject, filepath)
"""
import odoo.modules as addons
adps = odoo.addons.__path__
rtp = os.path.normcase(os.path.abspath(config['root_path']))
@@ -206,7 +198,6 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False):
def _fileopen(path, mode, basedir, pathinfo, basename=None):
name = os.path.normpath(os.path.normcase(os.path.join(basedir, path)))
import odoo.modules as addons
paths = odoo.addons.__path__ + [config['root_path']]
for addons_path in paths:
addons_path = os.path.normpath(os.path.normcase(addons_path)) + os.sep