Skip to content

Commit

Permalink
Require python >= 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed May 21, 2022
1 parent 860b74e commit be6b4ab
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 228 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "2.7"
toxenv: "py27-8.0"
- python-version: "2.7"
toxenv: "py27-9.0"
- python-version: "2.7"
toxenv: "py27-10.0"
- python-version: "3.5"
- python-version: "3.6"
toxenv: "py35-11.0"
- python-version: "3.6"
toxenv: "py36-12.0"
Expand Down
9 changes: 1 addition & 8 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
[settings]
; see https://github.com/ambv/black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
use_parentheses=True
line_length=88
known_third_party = click,click_odoo,mock,psycopg2,pytest,setuptools
profile = black
20 changes: 5 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
exclude: "^tests/data/.*$"
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
language_version: python3
additional_dependencies:
- "click<8.1"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- repo: https://github.com/pycqa/flake8
rev: 3.8.3
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
rev: v2.32.1
hooks:
- id: pyupgrade
language_version: python3
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
language_version: python3
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.5.4
rev: v5.10.1
hooks:
- id: isort
language_version: python3
6 changes: 1 addition & 5 deletions click_odoo_contrib/_dbutils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV (<http://acsone.eu>)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

Expand Down Expand Up @@ -75,10 +74,7 @@ def reset_config_parameters(dbname):
(dbuuid, ...)
"""
with OdooEnvironment(dbname) as env:
if odoo.release.version_info < (10, 0):
env.registry("ir.config_parameter").init(env.cr, force=True)
else:
env["ir.config_parameter"].init(force=True)
env["ir.config_parameter"].init(force=True)

# reset enterprise keys if exists
env.cr.execute(
Expand Down
1 change: 0 additions & 1 deletion click_odoo_contrib/backupdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV (<http://acsone.eu>)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

Expand Down
1 change: 0 additions & 1 deletion click_odoo_contrib/copydb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV (<http://acsone.eu>)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

Expand Down
1 change: 0 additions & 1 deletion click_odoo_contrib/core_addons/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2020 ACSONE SA/NV
# License LGPLv3 (http://www.gnu.org/licenses/lgpl-3.0-standalone.html)
"""List of Odoo official addons."""
Expand Down
3 changes: 1 addition & 2 deletions click_odoo_contrib/dropdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV (<http://acsone.eu>)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

Expand All @@ -21,7 +20,7 @@
)
@click.argument("dbname", nargs=1)
def main(env, dbname, if_exists=False):
""" Drop an Odoo database and associated file store. """
"""Drop an Odoo database and associated file store."""
if not db_exists(dbname):
msg = "Database does not exist: {}".format(dbname)
if if_exists:
Expand Down
13 changes: 4 additions & 9 deletions click_odoo_contrib/initdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV (<http://acsone.eu>)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import contextlib
Expand Down Expand Up @@ -51,12 +50,8 @@ def _db_storage(self):
# when recreating the db by copying the cached template
if _odoo_version >= odoo.tools.parse_version("12"):
from odoo.addons.base.models.ir_attachment import IrAttachment
elif _odoo_version >= odoo.tools.parse_version("10"):
from odoo.addons.base.ir.ir_attachment import IrAttachment
else:
from openerp.addons.base.ir.ir_attachment import (
ir_attachment as IrAttachment,
)
from odoo.addons.base.ir.ir_attachment import IrAttachment
orig = IrAttachment._storage
IrAttachment._storage = _db_storage
try:
Expand Down Expand Up @@ -197,7 +192,7 @@ def _drop_db(self, dbname):
)

def _find_template(self, hashsum):
""" search same prefix and hashsum, any date """
"""search same prefix and hashsum, any date"""
pattern = self.prefix + "-____________-" + hashsum
self.pgcr.execute(
"""
Expand All @@ -221,7 +216,7 @@ def _touch(self, template_name, hashsum):
self._rename_db(template_name, new_template_name)

def create(self, new_database, hashsum):
""" Create a new database from a cached template matching hashsum """
"""Create a new database from a cached template matching hashsum"""
with self._lock():
template_name = self._find_template(hashsum)
if not template_name:
Expand All @@ -232,7 +227,7 @@ def create(self, new_database, hashsum):
return True

def add(self, new_database, hashsum):
""" Create a new cached template """
"""Create a new cached template"""
with self._lock():
template_name = self._find_template(hashsum)
if template_name:
Expand Down
2 changes: 1 addition & 1 deletion click_odoo_contrib/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def read_manifest(addon_dir):


def find_addons(addons_dir, installable_only=True):
""" yield (addon_name, addon_dir, manifest) """
"""yield (addon_name, addon_dir, manifest)"""
for addon_name in sorted(os.listdir(addons_dir)):
addon_dir = os.path.join(addons_dir, addon_name)
try:
Expand Down
1 change: 0 additions & 1 deletion click_odoo_contrib/restoredb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

Expand Down
5 changes: 1 addition & 4 deletions click_odoo_contrib/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def run(self):
"""
# See https://stackoverflow.com/a/35319598/1468388
terminate_session = "SELECT pg_terminate_backend(%s)"
if odoo.release.version_info < (9, 0):
params = {"dsn": odoo.sql_db.dsn(self.database)[1]}
else:
params = odoo.sql_db.connection_info_for(self.database)[1]
params = odoo.sql_db.connection_info_for(self.database)[1]
# Need a separate raw psycopg2 cursor without transactioning to avoid
# weird concurrency errors; this cursor will only trigger SELECTs, and
# it needs to access current Postgres server status, monitoring other
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"click-odoo>=1.3.0",
"importlib_resources ; python_version<'3.9'",
],
python_requires=">=3.6",
license="LGPLv3+",
author="ACSONE SA/NV",
author_email="info@acsone.eu",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from odoo import models, fields
except ImportError:
from openerp import models, fields
from odoo import models, fields


class TestModel(models.Model):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from odoo import models, fields
except ImportError:
from openerp import models, fields
from odoo import models, fields


class TestModel2(models.Model):
Expand Down
5 changes: 1 addition & 4 deletions tests/data/test_update/v6/addon_app/res_users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from odoo import models, fields
except ImportError:
from openerp import models, fields
from odoo import models, fields


class ResUsers(models.Model):
Expand Down
5 changes: 1 addition & 4 deletions tests/data/test_update/v7/addon_app/res_users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from odoo import models, fields
except ImportError:
from openerp import models, fields
from odoo import models, fields


class ResUsers(models.Model):
Expand Down
20 changes: 4 additions & 16 deletions tests/scripts/install_odoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@
def odoo_installed():
try:
import odoo # noqa

return True
except ImportError:
# odoo < 10
try:
import openerp # noqa

return True
except ImportError:
# odoo not installed
return False
return False
else:
return True


def odoo_cloned():
Expand All @@ -39,15 +32,10 @@ def clone_odoo():
odoo_dir,
]
)
if "PGHOST" in os.environ and odoo_branch == "8.0":
# Patch postgres connection mechanism to support connection with PGHOST
# environment variable. This patch is a backport from 9.0.
patch_path = os.path.join(os.path.dirname(__file__), "sql_db-8.patch")
subprocess.check_call(["patch", "-p1", "-i", patch_path], cwd=odoo_dir)


def install_odoo():
if odoo_branch in ["8.0", "9.0", "10.0", "11.0", "12.0", "13.0"]:
if odoo_branch in ["11.0", "12.0", "13.0"]:
# setuptools 58 dropped support for 2to3, which is required
# for dependencies of older Odoo versions
subprocess.check_call(
Expand Down

0 comments on commit be6b4ab

Please sign in to comment.