Skip to content

Commit 042cb4d

Browse files
authored
Merge pull request #634 from acsone/add-ruff
Add basic ruff config
2 parents fbdc894 + 47ee48f commit 042cb4d

29 files changed

+70
-58
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
exclude: |
22
(?x)
33
^template/
4-
default_language_version:
5-
python: python3
64
repos:
7-
- repo: https://github.com/PyCQA/flake8
8-
rev: 3.9.2
5+
- repo: https://github.com/astral-sh/ruff-pre-commit
6+
rev: v0.7.0
97
hooks:
10-
- id: flake8
11-
name: flake8
12-
- repo: https://github.com/psf/black
13-
rev: 22.8.0
14-
hooks:
15-
- id: black
8+
- id: ruff
9+
args: [--fix]
10+
- id: ruff-format

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0-standalone.html)
22
import os
3-
import setuptools
43

4+
import setuptools
55

66
here = os.path.dirname(os.path.abspath(__file__))
77
with open(os.path.join(here, "README.md")) as f:

tests/test_fix_manifest_website.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from tools.fix_manifest_website import main
2-
31
from click.testing import CliRunner
42

3+
from tools.fix_manifest_website import main
4+
55

66
def test_fix_manifest_website(tmp_path):
77
(tmp_path / "a1").mkdir()

tests/test_gen_addon_icon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import sys
88

9-
from tools.gen_addon_icon import ICONS_DIR, ICON_TYPE
9+
from tools.gen_addon_icon import ICON_TYPE, ICONS_DIR
1010

1111

1212
def test_gen_addon_icon(tmp_path):

tests/test_gen_addon_readme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
import pytest
1111

1212
from tools.gen_addon_readme import (
13+
_get_source_digest,
1314
get_fragment_format,
1415
get_fragments_format,
1516
safe_remove,
16-
_get_source_digest,
1717
)
1818

1919

tests/test_hash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from tools._hash import hash, _walk
2-
31
import pytest
42

3+
from tools._hash import _walk, hash
4+
55

66
def test_hash(tmp_path):
77
def populate(top):

tests/test_manifest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from tools import manifest
66

7-
87
HERE = os.path.dirname(__file__)
98
TEST_REPO_DIR = os.path.join(HERE, "test_repo")
109

tests/test_towncrier.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77
import toml
88
from click.testing import CliRunner
9+
910
from tools.oca_towncrier import _make_issue_format, _prepare_config, oca_towncrier
1011

1112

tests/test_update_pre_commit_excluded_addons.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import unicode_literals
2+
23
import subprocess
34
import textwrap
45

tools/add-badges.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import re
1+
import fileinput
22
import os
3+
import pdb
4+
import re
5+
import shutil
36
import subprocess
4-
import fileinput
57
import sys
6-
import shutil
7-
import pdb
88

99
# Runbot urls need the repo id from the table in the runbot server.
1010
# This file is the output of a select id, name from there.

tools/clone_everything.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0-standalone.html)
33

44
import argparse
5+
import os
56
import subprocess
67

78
from .oca_projects import OCA_REPOSITORY_NAMES, url
8-
import os
99

1010

1111
def clone(organization_remotes=None, remove_old_repos=False, target_branch=False):

tools/configure_travis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import click
33
import requests
44

5-
65
OCA_TRAVIS_GITHUB_USER = "oca-travis"
76
OCA_TRAVIS_GITHUB_EMAIL = "oca+oca-travis@odoo-community.org"
87

tools/copier_update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""Run copier update on a branch in all addons repos.
2-
"""
1+
"""Run copier update on a branch in all addons repos."""
2+
33
import subprocess
44
import textwrap
55
from pathlib import Path
@@ -9,7 +9,7 @@
99
import requests
1010

1111
from .gitutils import commit_if_needed
12-
from .oca_projects import BranchNotFoundError, temporary_clone, get_repositories
12+
from .oca_projects import BranchNotFoundError, get_repositories, temporary_clone
1313

1414
IGNORED_REJ_FILES = ["oca_dependencies.txt.rej"]
1515

tools/copy_maintainers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0-standalone.html)
3-
from __future__ import absolute_import, print_function
4-
53
"""
64
oca-copy-maintainers
75
@@ -10,15 +8,15 @@
108
119
"""
1210

11+
from __future__ import absolute_import, print_function
12+
1313
import argparse
1414
import errno
1515
import os
1616
import sys
1717
from operator import attrgetter
18-
from . import github_login
19-
from . import odoo_login
20-
from . import colors
2118

19+
from . import colors, github_login, odoo_login
2220

2321
COPY_USERS_BLACKLIST = os.environ.get(
2422
"COPY_USERS_BLACKLIST", "~/.config/oca-copy-maintainers/copy_users_blacklist.txt"

tools/create_branch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
TODO
44
- load copier answers from a previous branch
55
"""
6+
67
import subprocess
78

89
import click

tools/create_migration_issue.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@
8181
"""
8282

8383
from __future__ import print_function
84+
8485
import argparse
85-
from . import github_login
86-
from . import oca_projects
87-
from .config import read_config
8886

8987
import github3
9088

89+
from . import github_login, oca_projects
90+
from .config import read_config
91+
9192
MANIFESTS = ("__openerp__.py", "__manifest__.py")
9293

9394

tools/fix_manifest_website.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Set the website key in addons manifests."""
2+
23
import os
34
import re
45

56
import click
67

78
from .manifest import get_manifest_path, parse_manifest
89

9-
1010
WEBSITE_KEY_RE = re.compile(r"""(["']website["']\s*:\s*["'])([^"']*)(["'])""")
1111

1212

tools/gen_addon_icon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import os
66
import shutil
7+
78
import click
89

910
from .gitutils import commit_if_needed
10-
from .manifest import read_manifest, find_addons, NoManifestFound
11-
11+
from .manifest import NoManifestFound, find_addons, read_manifest
1212

1313
ICONS_DIR = os.path.join("static", "description")
1414

tools/gen_addon_readme.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
from urllib.parse import urljoin
1414

1515
import click
16+
import pypandoc
1617
from docutils.core import publish_file
1718
from jinja2 import Template
18-
import pypandoc
1919

20-
from .gitutils import commit_if_needed
21-
from .manifest import get_manifest_path, read_manifest, find_addons, NoManifestFound
2220
from ._hash import hash
21+
from .gitutils import commit_if_needed
22+
from .manifest import NoManifestFound, find_addons, get_manifest_path, read_manifest
2323

2424
if sys.version_info >= (3, 8):
2525
from typing import Literal

tools/gen_addons_table.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919

2020
from __future__ import print_function
21+
2122
import ast
2223
import io
2324
import logging

tools/gen_metapackage.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
from pathlib import Path
88
from typing import Any, List, Optional
99

10-
10+
from manifestoo_core.addon import Addon, is_addon_dir
11+
from manifestoo_core.metadata import addon_name_to_requirement
1112
from manifestoo_core.odoo_series import (
1213
OdooSeries,
14+
)
15+
from manifestoo_core.odoo_series import (
1316
detect_from_addon_version as detect_odoo_series_from_addon_version,
1417
)
15-
from manifestoo_core.addon import is_addon_dir, Addon
16-
from manifestoo_core.metadata import addon_name_to_requirement
1718

1819
from .compat import tomllib
1920

tools/github_login.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import os
77
import subprocess
88
from getpass import getpass
9+
910
import github3
11+
1012
from .config import read_config, write_config
1113

1214

tools/migrate_branch.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@
8787
"""
8888

8989
from __future__ import print_function
90+
9091
import argparse
9192
import re
92-
from . import github_login
93-
from . import oca_projects
94-
from .config import read_config
93+
9594
from github3.exceptions import NotFoundError
9695

96+
from . import github_login, oca_projects
97+
from .config import read_config
98+
9799
MANIFESTS = ("__openerp__.py", "__manifest__.py")
98100

99101

tools/migrate_branch_empty.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@
8989
"""
9090

9191
from __future__ import print_function
92+
9293
import argparse
9394
import re
94-
from . import github_login
95-
from . import oca_projects
96-
from .config import read_config
95+
9796
from github3.exceptions import NotFoundError
9897

98+
from . import github_login, oca_projects
99+
from .config import read_config
100+
99101
MANIFESTS = ("__openerp__.py", "__manifest__.py")
100102

101103

tools/oca_projects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
OCA_REPOSITORY_NAMES: list of OCA repository names
77
88
"""
9+
910
from __future__ import print_function
10-
from contextlib import contextmanager
11+
1112
import os
1213
import shutil
1314
import subprocess
1415
import tempfile
16+
from contextlib import contextmanager
1517

1618
import appdirs
19+
1720
from .config import NOT_ADDONS, is_main_branch
1821
from .github_login import login
1922

tools/oca_sync_users.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
77
This enables adding them to project teams in the OCA instance.
88
"""
9+
910
from __future__ import absolute_import, print_function
1011

1112
import xmlrpclib
1213

13-
from .odoo_login import login, get_parser
14+
from .odoo_login import get_parser, login
1415

1516

1617
def main():

tools/odoo_login.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
import argparse
66
import os
77
import sys
8-
import erppeek
98
from getpass import getpass
10-
from .config import read_config, write_config
119

10+
import erppeek
11+
12+
from .config import read_config, write_config
1213

1314
ODOO_URL = os.environ.get("ODOO_URL", "https://odoo-community.org")
1415
ODOO_DB = os.environ.get("ODOO_DB", "odoo_community_prod")
@@ -58,7 +59,7 @@ def get_parser(with_help=False):
5859
action="store_true",
5960
help="Store the username and password in a "
6061
"configuration file. Warning, clear text!",
61-
),
62+
)
6263
return parser
6364

6465

tools/publish_modules.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,18 @@
6161
"""
6262

6363
from __future__ import print_function
64+
6465
import logging
6566
from getpass import getpass
67+
6668
import click
67-
from selenium.common.exceptions import NoSuchElementException
6869
from selenium import webdriver
69-
from selenium.webdriver.support.ui import WebDriverWait
70+
from selenium.common.exceptions import NoSuchElementException
7071
from selenium.webdriver.chrome.options import Options
72+
from selenium.webdriver.support.ui import WebDriverWait
7173

72-
from .oca_projects import get_repositories_and_branches, url
7374
from .config import read_config
75+
from .oca_projects import get_repositories_and_branches, url
7476

7577
_logger = logging.getLogger(__name__)
7678

0 commit comments

Comments
 (0)