Use last python image for linting

The linting check can be done on any docker image with the latest python
version.

This updates de pre-commit checks and fix file linting to conform to new
standards.
This commit is contained in:
Rémy Taymans 2023-11-09 16:39:40 +01:00
parent 690ab60699
commit 6a36c97ee4
10 changed files with 6 additions and 17 deletions

View File

@ -5,9 +5,8 @@ stages:
- release - release
pre-commit: pre-commit:
image: python
stage: lint stage: lint
tags:
- shell
only: only:
- merge_requests - merge_requests
before_script: before_script:

View File

@ -2,7 +2,7 @@
exclude: '^tests/data/output_expected/' exclude: '^tests/data/output_expected/'
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0 rev: v4.5.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
@ -19,15 +19,15 @@ repos:
- id: check-merge-conflict - id: check-merge-conflict
- id: check-symlinks - id: check-symlinks
- repo: https://github.com/pre-commit/mirrors-isort - repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0 rev: v5.10.1
hooks: hooks:
- id: isort - id: isort
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 23.11.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
rev: "3.9.2" rev: "6.1.0"
hooks: hooks:
- id: flake8 - id: flake8
# - repo: https://gitlab.com/smop/pre-commit-hooks # - repo: https://gitlab.com/smop/pre-commit-hooks

View File

@ -27,7 +27,6 @@ def docker_build(ctx, versions):
# Build images for each odoo version # Build images for each odoo version
for odoo_version in get_odoo_versions_from_options(ctx, versions): for odoo_version in get_odoo_versions_from_options(ctx, versions):
odoo_requirement_file_path = ( odoo_requirement_file_path = (
get_odoo_env_path(ctx, odoo_version) / "src/odoo/requirements.txt" get_odoo_env_path(ctx, odoo_version) / "src/odoo/requirements.txt"
) )

View File

@ -33,7 +33,6 @@ from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_writable
) )
@click.pass_context @click.pass_context
def generate_module_analysis(ctx, step, database, modules): def generate_module_analysis(ctx, step, database, modules):
migration_steps = get_migration_steps_from_options(ctx, step - 1, step) migration_steps = get_migration_steps_from_options(ctx, step - 1, step)
initial_step = migration_steps[0].copy() initial_step = migration_steps[0].copy()

View File

@ -67,7 +67,6 @@ def database_option_required(function):
def get_odoo_versions_from_options(ctx, versions_arg): def get_odoo_versions_from_options(ctx, versions_arg):
if not versions_arg: if not versions_arg:
return ctx.obj["config"]["odoo_versions"] return ctx.obj["config"]["odoo_versions"]
else: else:

View File

@ -23,7 +23,6 @@ from odoo_openupgrade_wizard.tools.tools_postgres import (
@database_option_required @database_option_required
@click.pass_context @click.pass_context
def upgrade(ctx, first_step, last_step, database): def upgrade(ctx, first_step, last_step, database):
migration_steps = get_migration_steps_from_options( migration_steps = get_migration_steps_from_options(
ctx, first_step, last_step ctx, first_step, last_step
) )

View File

@ -107,7 +107,6 @@ def generate_odoo_command(
stop_after_init: bool = False, stop_after_init: bool = False,
shell: bool = False, shell: bool = False,
) -> str: ) -> str:
odoo_env_path = get_odoo_env_path(ctx, migration_step["version"]) odoo_env_path = get_odoo_env_path(ctx, migration_step["version"])
# Compute 'server_wide_modules' # Compute 'server_wide_modules'
@ -295,7 +294,6 @@ def execute_click_odoo_python_files(
python_files: list = [], python_files: list = [],
execution_context: str = False, execution_context: str = False,
): ):
if not python_files: if not python_files:
# Get post-migration python scripts to execute # Get post-migration python scripts to execute
script_folder = get_script_folder(ctx, migration_step) script_folder = get_script_folder(ctx, migration_step)

View File

@ -10,7 +10,6 @@ _ODOO_RPC_URL = "0.0.0.0"
class OdooInstance: class OdooInstance:
env = False env = False
version = False version = False
@ -84,7 +83,7 @@ class OdooInstance:
return model.browse(model.create(vals)) return model.browse(model.create(vals))
def install_modules(self, module_names): def install_modules(self, module_names):
if type(module_names) == str: if type(module_names) is str:
module_names = [module_names] module_names = [module_names]
installed_modules = [] installed_modules = []
i = 0 i = 0

View File

@ -117,7 +117,6 @@ class Analysis(object):
# Instanciate a new odoo_module # Instanciate a new odoo_module
for module_name in module_list: for module_name in module_list:
addon_path = OdooModule.get_addon_path( addon_path = OdooModule.get_addon_path(
ctx, module_name, self.initial_version ctx, module_name, self.initial_version
) )
@ -476,7 +475,6 @@ class OdooModule(object):
class OdooModuleVersion(object): class OdooModuleVersion(object):
_exclude_directories = [ _exclude_directories = [
"lib", "lib",
"demo", "demo",

View File

@ -84,7 +84,6 @@ def ensure_file_exists_from_template(
def git_aggregate(folder_path: Path, config_path: Path, jobs: int): def git_aggregate(folder_path: Path, config_path: Path, jobs: int):
args = argparse.Namespace( args = argparse.Namespace(
command="aggregate", command="aggregate",
config=str(config_path), config=str(config_path),