Skip to content

Commit

Permalink
[REF] pre_commit_vauxoo: pylint checks support define python version
Browse files Browse the repository at this point in the history
variables.sh has 'TRAVIS_PYTHON_VERSION' with the python version to use for each project
  • Loading branch information
moylop260 committed Jan 10, 2025
1 parent e331f82 commit 1dbd247
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pre_commit_vauxoo/cfg/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ persistent=yes
# This extension are not used for this configuration file but are useful to process disable comments based on these ones
load-plugins=pylint.extensions.docstyle, pylint.extensions.mccabe, pylint_odoo
extension-pkg-whitelist=lxml
# External scripts main replace

[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
Expand Down
1 change: 1 addition & 0 deletions src/pre_commit_vauxoo/cfg/.pylintrc-optional
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ profile=no
ignore=CVS,.git,scenarios,.bzr
persistent=yes
load-plugins=pylint.extensions.docstyle, pylint.extensions.mccabe, pylint_odoo
# External scripts main replace

[ODOOLINT]
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
Expand Down
7 changes: 7 additions & 0 deletions src/pre_commit_vauxoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ def precommit_hooks_type_callback(ctx, param, value):
help="Odoo version used for the repository.",
**new_extra_kwargs,
)
@click.option(
"--py-version",
envvar="TRAVIS_PYTHON_VERSION",
type=click.STRING,
help="Python version used for the repository.",
**new_extra_kwargs,
)
def main(*args, **kwargs):
"""pre-commit-vauxoo run pre-commit with custom validations and configuration files"""
version = kwargs.pop("version", None)
Expand Down
9 changes: 9 additions & 0 deletions src/pre_commit_vauxoo/pre_commit_vauxoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def get_uninstallable_modules(src_path) -> set:
return results


# copy_cfg_files has too many "for-if" sentences
# because it is a switch-case dummy logic
# TODO: Migrate this method to use configuration files with jinja template
# pylint: disable=too-complex
def copy_cfg_files(
precommit_config_dir,
repo_dirname,
Expand All @@ -87,6 +91,7 @@ def copy_cfg_files(
exclude_autofix,
skip_string_normalization,
odoo_version,
py_version,
):
exclude_lint_regex = ""
exclude_autofix_regex = ""
Expand Down Expand Up @@ -139,6 +144,8 @@ def copy_cfg_files(
if fname.startswith(".pylintrc"):
if "# External scripts odoo_lint replace" in line and odoo_version:
line += "valid-odoo-version=%s\n" % odoo_version
elif py_version and line.startswith("# External scripts main replace"):
line += f"py-version={py_version}\n"
fdst.write(line)


Expand Down Expand Up @@ -184,6 +191,7 @@ def main(
install,
skip_string_normalization,
odoo_version,
py_version,
do_exit=True,
):
show_version()
Expand Down Expand Up @@ -215,6 +223,7 @@ def main(
exclude_autofix,
skip_string_normalization,
odoo_version,
py_version,
)
_logger.info("Installing pre-commit hooks")
cmd = ["pre-commit", "install-hooks", "--color=always"]
Expand Down
1 change: 1 addition & 0 deletions variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export PRECOMMIT_HOOKS_TYPE="all"
export EXCLUDE_LINT="resources/module_warnings1,resources/module_uninstallable"
export EXCLUDE_AUTOFIX="resources/module_autofix1"
export VERSION="16.0"
export TRAVIS_PYTHON_VERSION="3.13"

0 comments on commit 1dbd247

Please sign in to comment.