Skip to content

Commit 5952928

Browse files
author
Adrian Torres
committed
[REM] *: remove various unused import shims
Before this commit, a lot of leftover import shims existed in the codebase for py2-py3 compatibility, these are no longer needed since Odoo 13.0+ doesn't support Python 2 anymore and is (finally) in EOL. With this commit, these shims are dropped, making the code cleaner, easier to read and with one less dependency. Queue -> queue -> py2-py3 compatibility xmlrpclib -> xmlrpc.client -> py2-py3 compatibility ConfigParser -> configparser -> py2-py3 compatibility itertools.izip_longest -> itertools.zip_longest -> py2-py3 compatibility urllib -> urllib.request -> py2-py3 compatibility __builtins__ -> builtins -> py2-py3 compatibility _winreg -> winreg -> py2-py3 compatibility mock -> unittest.mock -> merged into CPython The debian/fedora packages and requirements.txt have been updated accordingly closes odoo#44601 Related: odoo/enterprise#8141 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
1 parent c248594 commit 5952928

File tree

23 files changed

+23
-98
lines changed

23 files changed

+23
-98
lines changed

addons/base_vat/tests/test_validate_ruc.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22
from odoo.tests import common
33
from odoo.exceptions import ValidationError
4-
try:
5-
from unittest.mock import patch
6-
except ImportError:
7-
from mock import patch
4+
from unittest.mock import patch
85

96
from stdnum.eu import vat
107

addons/hw_drivers/drivers/KeyboardUSBDriver.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
from threading import Lock
1414
from usb import util
1515
import urllib3
16-
try:
17-
from queue import Queue, Empty
18-
except ImportError:
19-
from Queue import Queue, Empty # pylint: disable=deprecated-module
16+
from queue import Queue, Empty
2017

2118
from odoo import http, _
2219
from odoo.addons.hw_proxy.controllers.main import drivers as old_drivers

addons/hw_escpos/controllers/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
except ImportError:
1919
escpos = printer = None
2020

21-
try:
22-
from queue import Queue
23-
except ImportError:
24-
from Queue import Queue # pylint: disable=deprecated-module
21+
from queue import Queue
2522
from threading import Thread, Lock
2623

2724
try:

addons/l10n_it_edi/models/ir_mail_server.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@
1010
import dateutil
1111
import pytz
1212
import base64
13-
try:
14-
from xmlrpc import client as xmlrpclib
15-
except ImportError:
16-
import xmlrpclib
17-
1813

1914
from lxml import etree
2015
from datetime import datetime
16+
from xmlrpc import client as xmlrpclib
2117

2218
from odoo import api, fields, models, tools, _
2319
from odoo.exceptions import ValidationError, UserError

addons/mail/models/mail_thread.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
import socket
1717
import time
1818
import threading
19-
try:
20-
from xmlrpc import client as xmlrpclib
21-
except ImportError:
22-
import xmlrpclib
2319

2420
from collections import namedtuple
2521
from email.message import EmailMessage
2622
from lxml import etree
2723
from werkzeug import urls
24+
from xmlrpc import client as xmlrpclib
2825

2926
from odoo import _, api, exceptions, fields, models, tools, registry, SUPERUSER_ID
3027
from odoo.exceptions import MissingError

addons/mass_mailing/tests/test_mass_mailing_shortener.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33

44
from odoo.tests import common
55
from lxml import etree
6-
7-
try:
8-
from unittest.mock import patch
9-
except ImportError:
10-
from mock import patch
6+
from unittest.mock import patch
117

128

139
class TestMassMailingShortener(common.TransactionCase):

addons/website/tests/test_views.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4-
try:
5-
from itertools import zip_longest
6-
except ImportError:
7-
from itertools import izip_longest as zip_longest
8-
94
import unittest
5+
from itertools import zip_longest
106
from lxml import etree as ET, html
117
from lxml.html import builder as h
128

addons/website/tests/test_website_reset_password.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4-
try:
5-
from unittest.mock import patch
6-
except ImportError:
7-
from mock import patch
4+
from unittest.mock import patch
85

96
import odoo
107
from odoo.tests import tagged

addons/website_crm_partner_assign/tests/test_partner_assign.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4-
try:
5-
from unittest.mock import patch
6-
except ImportError:
7-
from mock import patch
8-
from odoo.exceptions import AccessError
4+
from unittest.mock import patch
95

6+
from odoo.exceptions import AccessError
107
from odoo.tests.common import TransactionCase
118
from odoo.addons.crm.tests.common import TestCrmCommon
129
from odoo.addons.mail.tests.common import mail_new_test_user

addons/website_sale/tests/test_website_sale_mail.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4-
try:
5-
from unittest.mock import patch
6-
except ImportError:
7-
from mock import patch
4+
from unittest.mock import patch
85

96
import odoo
107
from odoo.tests import tagged

0 commit comments

Comments
 (0)