diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db0b4ee9..5df97025 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,10 @@ exclude: | (?x) ^template/ -default_language_version: - python: python3 repos: - - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.7.0 hooks: - - id: flake8 - name: flake8 - - repo: https://github.com/psf/black - rev: 22.8.0 - hooks: - - id: black + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/setup.py b/setup.py index 9cd6efa7..8c3749a0 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0-standalone.html) import os -import setuptools +import setuptools here = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(here, "README.md")) as f: diff --git a/tests/test_fix_manifest_website.py b/tests/test_fix_manifest_website.py index afe5d679..f0869f74 100644 --- a/tests/test_fix_manifest_website.py +++ b/tests/test_fix_manifest_website.py @@ -1,7 +1,7 @@ -from tools.fix_manifest_website import main - from click.testing import CliRunner +from tools.fix_manifest_website import main + def test_fix_manifest_website(tmp_path): (tmp_path / "a1").mkdir() diff --git a/tests/test_gen_addon_icon.py b/tests/test_gen_addon_icon.py index 9c8cd136..c675f71d 100644 --- a/tests/test_gen_addon_icon.py +++ b/tests/test_gen_addon_icon.py @@ -6,7 +6,7 @@ import subprocess import sys -from tools.gen_addon_icon import ICONS_DIR, ICON_TYPE +from tools.gen_addon_icon import ICON_TYPE, ICONS_DIR def test_gen_addon_icon(tmp_path): diff --git a/tests/test_gen_addon_readme.py b/tests/test_gen_addon_readme.py index f244f2a9..37555205 100644 --- a/tests/test_gen_addon_readme.py +++ b/tests/test_gen_addon_readme.py @@ -10,10 +10,10 @@ import pytest from tools.gen_addon_readme import ( + _get_source_digest, get_fragment_format, get_fragments_format, safe_remove, - _get_source_digest, ) diff --git a/tests/test_hash.py b/tests/test_hash.py index 315e5476..c303b849 100644 --- a/tests/test_hash.py +++ b/tests/test_hash.py @@ -1,7 +1,7 @@ -from tools._hash import hash, _walk - import pytest +from tools._hash import _walk, hash + def test_hash(tmp_path): def populate(top): diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 2469059c..57cec819 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -4,7 +4,6 @@ from tools import manifest - HERE = os.path.dirname(__file__) TEST_REPO_DIR = os.path.join(HERE, "test_repo") diff --git a/tests/test_towncrier.py b/tests/test_towncrier.py index df93bcd0..3f407a75 100644 --- a/tests/test_towncrier.py +++ b/tests/test_towncrier.py @@ -6,6 +6,7 @@ import pytest import toml from click.testing import CliRunner + from tools.oca_towncrier import _make_issue_format, _prepare_config, oca_towncrier diff --git a/tests/test_update_pre_commit_excluded_addons.py b/tests/test_update_pre_commit_excluded_addons.py index 364e477e..1a696045 100644 --- a/tests/test_update_pre_commit_excluded_addons.py +++ b/tests/test_update_pre_commit_excluded_addons.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + import subprocess import textwrap diff --git a/tools/add-badges.py b/tools/add-badges.py index 3e4eaf7a..275fe9b3 100644 --- a/tools/add-badges.py +++ b/tools/add-badges.py @@ -1,10 +1,10 @@ -import re +import fileinput import os +import pdb +import re +import shutil import subprocess -import fileinput import sys -import shutil -import pdb # Runbot urls need the repo id from the table in the runbot server. # This file is the output of a select id, name from there. diff --git a/tools/clone_everything.py b/tools/clone_everything.py index fd5ddc0a..c9e51825 100644 --- a/tools/clone_everything.py +++ b/tools/clone_everything.py @@ -2,10 +2,10 @@ # License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0-standalone.html) import argparse +import os import subprocess from .oca_projects import OCA_REPOSITORY_NAMES, url -import os def clone(organization_remotes=None, remove_old_repos=False, target_branch=False): diff --git a/tools/configure_travis.py b/tools/configure_travis.py index d89897c8..575f6a6b 100644 --- a/tools/configure_travis.py +++ b/tools/configure_travis.py @@ -2,7 +2,6 @@ import click import requests - OCA_TRAVIS_GITHUB_USER = "oca-travis" OCA_TRAVIS_GITHUB_EMAIL = "oca+oca-travis@odoo-community.org" diff --git a/tools/copier_update.py b/tools/copier_update.py index 2c8b62af..3acf5135 100644 --- a/tools/copier_update.py +++ b/tools/copier_update.py @@ -1,5 +1,5 @@ -"""Run copier update on a branch in all addons repos. -""" +"""Run copier update on a branch in all addons repos.""" + import subprocess import textwrap from pathlib import Path @@ -9,7 +9,7 @@ import requests from .gitutils import commit_if_needed -from .oca_projects import BranchNotFoundError, temporary_clone, get_repositories +from .oca_projects import BranchNotFoundError, get_repositories, temporary_clone IGNORED_REJ_FILES = ["oca_dependencies.txt.rej"] diff --git a/tools/copy_maintainers.py b/tools/copy_maintainers.py index 57ad69ea..45a5199b 100644 --- a/tools/copy_maintainers.py +++ b/tools/copy_maintainers.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0-standalone.html) -from __future__ import absolute_import, print_function - """ oca-copy-maintainers @@ -10,15 +8,15 @@ """ +from __future__ import absolute_import, print_function + import argparse import errno import os import sys from operator import attrgetter -from . import github_login -from . import odoo_login -from . import colors +from . import colors, github_login, odoo_login COPY_USERS_BLACKLIST = os.environ.get( "COPY_USERS_BLACKLIST", "~/.config/oca-copy-maintainers/copy_users_blacklist.txt" diff --git a/tools/create_branch.py b/tools/create_branch.py index 76b52390..bf501af0 100644 --- a/tools/create_branch.py +++ b/tools/create_branch.py @@ -3,6 +3,7 @@ TODO - load copier answers from a previous branch """ + import subprocess import click diff --git a/tools/create_migration_issue.py b/tools/create_migration_issue.py index 63bcc7ef..b9e739f5 100644 --- a/tools/create_migration_issue.py +++ b/tools/create_migration_issue.py @@ -81,13 +81,14 @@ """ from __future__ import print_function + import argparse -from . import github_login -from . import oca_projects -from .config import read_config import github3 +from . import github_login, oca_projects +from .config import read_config + MANIFESTS = ("__openerp__.py", "__manifest__.py") diff --git a/tools/fix_manifest_website.py b/tools/fix_manifest_website.py index 46c09a82..740a71eb 100644 --- a/tools/fix_manifest_website.py +++ b/tools/fix_manifest_website.py @@ -1,4 +1,5 @@ """Set the website key in addons manifests.""" + import os import re @@ -6,7 +7,6 @@ from .manifest import get_manifest_path, parse_manifest - WEBSITE_KEY_RE = re.compile(r"""(["']website["']\s*:\s*["'])([^"']*)(["'])""") diff --git a/tools/gen_addon_icon.py b/tools/gen_addon_icon.py index 05d409c6..e76596ee 100644 --- a/tools/gen_addon_icon.py +++ b/tools/gen_addon_icon.py @@ -4,11 +4,11 @@ import os import shutil + import click from .gitutils import commit_if_needed -from .manifest import read_manifest, find_addons, NoManifestFound - +from .manifest import NoManifestFound, find_addons, read_manifest ICONS_DIR = os.path.join("static", "description") diff --git a/tools/gen_addon_readme.py b/tools/gen_addon_readme.py index 5624244b..cb8831ea 100644 --- a/tools/gen_addon_readme.py +++ b/tools/gen_addon_readme.py @@ -13,13 +13,13 @@ from urllib.parse import urljoin import click +import pypandoc from docutils.core import publish_file from jinja2 import Template -import pypandoc -from .gitutils import commit_if_needed -from .manifest import get_manifest_path, read_manifest, find_addons, NoManifestFound from ._hash import hash +from .gitutils import commit_if_needed +from .manifest import NoManifestFound, find_addons, get_manifest_path, read_manifest if sys.version_info >= (3, 8): from typing import Literal diff --git a/tools/gen_addons_table.py b/tools/gen_addons_table.py index bd87eb7b..81f338d7 100755 --- a/tools/gen_addons_table.py +++ b/tools/gen_addons_table.py @@ -18,6 +18,7 @@ """ from __future__ import print_function + import ast import io import logging diff --git a/tools/gen_metapackage.py b/tools/gen_metapackage.py index ff1e43a7..864c3a01 100644 --- a/tools/gen_metapackage.py +++ b/tools/gen_metapackage.py @@ -7,13 +7,14 @@ from pathlib import Path from typing import Any, List, Optional - +from manifestoo_core.addon import Addon, is_addon_dir +from manifestoo_core.metadata import addon_name_to_requirement from manifestoo_core.odoo_series import ( OdooSeries, +) +from manifestoo_core.odoo_series import ( detect_from_addon_version as detect_odoo_series_from_addon_version, ) -from manifestoo_core.addon import is_addon_dir, Addon -from manifestoo_core.metadata import addon_name_to_requirement from .compat import tomllib diff --git a/tools/github_login.py b/tools/github_login.py index e253f620..f17a6767 100644 --- a/tools/github_login.py +++ b/tools/github_login.py @@ -6,7 +6,9 @@ import os import subprocess from getpass import getpass + import github3 + from .config import read_config, write_config diff --git a/tools/migrate_branch.py b/tools/migrate_branch.py index bd28313a..036970b0 100644 --- a/tools/migrate_branch.py +++ b/tools/migrate_branch.py @@ -87,13 +87,15 @@ """ from __future__ import print_function + import argparse import re -from . import github_login -from . import oca_projects -from .config import read_config + from github3.exceptions import NotFoundError +from . import github_login, oca_projects +from .config import read_config + MANIFESTS = ("__openerp__.py", "__manifest__.py") diff --git a/tools/migrate_branch_empty.py b/tools/migrate_branch_empty.py index 3fcaa81e..9b066ad6 100644 --- a/tools/migrate_branch_empty.py +++ b/tools/migrate_branch_empty.py @@ -89,13 +89,15 @@ """ from __future__ import print_function + import argparse import re -from . import github_login -from . import oca_projects -from .config import read_config + from github3.exceptions import NotFoundError +from . import github_login, oca_projects +from .config import read_config + MANIFESTS = ("__openerp__.py", "__manifest__.py") diff --git a/tools/oca_projects.py b/tools/oca_projects.py index 686ebd5d..5511ee6d 100644 --- a/tools/oca_projects.py +++ b/tools/oca_projects.py @@ -6,14 +6,17 @@ OCA_REPOSITORY_NAMES: list of OCA repository names """ + from __future__ import print_function -from contextlib import contextmanager + import os import shutil import subprocess import tempfile +from contextlib import contextmanager import appdirs + from .config import NOT_ADDONS, is_main_branch from .github_login import login diff --git a/tools/oca_sync_users.py b/tools/oca_sync_users.py index 2a759e52..4b0e088e 100644 --- a/tools/oca_sync_users.py +++ b/tools/oca_sync_users.py @@ -6,11 +6,12 @@ This enables adding them to project teams in the OCA instance. """ + from __future__ import absolute_import, print_function import xmlrpclib -from .odoo_login import login, get_parser +from .odoo_login import get_parser, login def main(): diff --git a/tools/odoo_login.py b/tools/odoo_login.py index 00611560..bdc6b1cc 100644 --- a/tools/odoo_login.py +++ b/tools/odoo_login.py @@ -5,10 +5,11 @@ import argparse import os import sys -import erppeek from getpass import getpass -from .config import read_config, write_config +import erppeek + +from .config import read_config, write_config ODOO_URL = os.environ.get("ODOO_URL", "https://odoo-community.org") ODOO_DB = os.environ.get("ODOO_DB", "odoo_community_prod") @@ -58,7 +59,7 @@ def get_parser(with_help=False): action="store_true", help="Store the username and password in a " "configuration file. Warning, clear text!", - ), + ) return parser diff --git a/tools/publish_modules.py b/tools/publish_modules.py index ac52e617..089e015d 100755 --- a/tools/publish_modules.py +++ b/tools/publish_modules.py @@ -61,16 +61,18 @@ """ from __future__ import print_function + import logging from getpass import getpass + import click -from selenium.common.exceptions import NoSuchElementException from selenium import webdriver -from selenium.webdriver.support.ui import WebDriverWait +from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.chrome.options import Options +from selenium.webdriver.support.ui import WebDriverWait -from .oca_projects import get_repositories_and_branches, url from .config import read_config +from .oca_projects import get_repositories_and_branches, url _logger = logging.getLogger(__name__) diff --git a/tools/set_repo_labels.py b/tools/set_repo_labels.py index 537d2711..55db000a 100644 --- a/tools/set_repo_labels.py +++ b/tools/set_repo_labels.py @@ -4,7 +4,9 @@ Create and modify labels on github to have same labels and same color on all repo """ + from __future__ import print_function + import click from .github_login import login