Skip to content

Commit

Permalink
Merge pull request #634 from acsone/add-ruff
Browse files Browse the repository at this point in the history
Add basic ruff config
  • Loading branch information
sbidoul authored Oct 20, 2024
2 parents fbdc894 + 47ee48f commit 042cb4d
Show file tree
Hide file tree
Showing 29 changed files with 70 additions and 58 deletions.
15 changes: 5 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fix_manifest_website.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gen_addon_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gen_addon_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_hash.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
1 change: 0 additions & 1 deletion tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from tools import manifest


HERE = os.path.dirname(__file__)
TEST_REPO_DIR = os.path.join(HERE, "test_repo")

Expand Down
1 change: 1 addition & 0 deletions tests/test_towncrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions tests/test_update_pre_commit_excluded_addons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import unicode_literals

import subprocess
import textwrap

Expand Down
8 changes: 4 additions & 4 deletions tools/add-badges.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tools/clone_everything.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion tools/configure_travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import click
import requests


OCA_TRAVIS_GITHUB_USER = "oca-travis"
OCA_TRAVIS_GITHUB_EMAIL = "[email protected]"

Expand Down
6 changes: 3 additions & 3 deletions tools/copier_update.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]

Expand Down
8 changes: 3 additions & 5 deletions tools/copy_maintainers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/create_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TODO
- load copier answers from a previous branch
"""

import subprocess

import click
Expand Down
7 changes: 4 additions & 3 deletions tools/create_migration_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
2 changes: 1 addition & 1 deletion tools/fix_manifest_website.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Set the website key in addons manifests."""

import os
import re

import click

from .manifest import get_manifest_path, parse_manifest


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


Expand Down
4 changes: 2 additions & 2 deletions tools/gen_addon_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions tools/gen_addon_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tools/gen_addons_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from __future__ import print_function

import ast
import io
import logging
Expand Down
7 changes: 4 additions & 3 deletions tools/gen_metapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tools/github_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import os
import subprocess
from getpass import getpass

import github3

from .config import read_config, write_config


Expand Down
8 changes: 5 additions & 3 deletions tools/migrate_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
8 changes: 5 additions & 3 deletions tools/migrate_branch_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
5 changes: 4 additions & 1 deletion tools/oca_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tools/oca_sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 4 additions & 3 deletions tools/odoo_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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


Expand Down
8 changes: 5 additions & 3 deletions tools/publish_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
Loading

0 comments on commit 042cb4d

Please sign in to comment.