Skip to content

Commit ecc09a2

Browse files
authored
Merge pull request #204 from GlodoUK/T9098
fix: pylint-odoo v8 configuration options ignored
2 parents 450a800 + 65b9fd5 commit ecc09a2

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/.pylintrc-mandatory.jinja

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ load-plugins=pylint_odoo
66
score=n
77

88
[ODOOLINT]
9+
{%- if odoo_version < 16 %}
910
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
1011
manifest_required_authors={{ org_name }}
1112
manifest_required_keys=license
1213
manifest_deprecated_keys=description,active
1314
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
1415
valid_odoo_versions={{ odoo_version }}
16+
{%- else %}
17+
readme-template-url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
18+
manifest-required-authors={{ org_name }}
19+
manifest-required-keys=license
20+
manifest-deprecated-keys=description,active
21+
license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
22+
valid-odoo-versions={{ odoo_version }}
23+
{%- endif %}
1524

1625
[MESSAGES CONTROL]
1726
disable=all

tests/test_copy.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pathlib import Path
22

3+
import packaging.version
34
import yaml
45
from copier.main import run_auto
56

@@ -12,6 +13,16 @@
1213
REPO_ID = 149
1314

1415

16+
def read_and_parse_precommit_rev(tmp_path: Path, repo: str):
17+
# Attempt to find the rev of a pre-commit repo.
18+
# If it found, return the actual version, if it's not return 0.0.0.
19+
config = yaml.safe_load((tmp_path / ".pre-commit-config.yaml").read_text())
20+
entry = next(
21+
filter(lambda r: r.get("repo", "") == repo, config.get("repos", [])), {}
22+
)
23+
return packaging.version.parse(entry.get("rev", "0.0.0"))
24+
25+
1526
def test_bootstrap(tmp_path: Path, odoo_version: float, cloned_template: Path):
1627
"""Test that a project is properly bootstrapped."""
1728
data = {
@@ -31,12 +42,20 @@ def test_bootstrap(tmp_path: Path, odoo_version: float, cloned_template: Path):
3142
pylintrc_mandatory = (tmp_path / ".pylintrc-mandatory").read_text()
3243
assert "disable=all\n" in pylintrc_mandatory
3344
assert "enable=" in pylintrc_mandatory
34-
assert f"valid_odoo_versions={odoo_version}" in pylintrc_mandatory
45+
pylint_odoo_version = read_and_parse_precommit_rev(
46+
tmp_path, "https://github.com/OCA/pylint-odoo"
47+
)
48+
valid_odoo_versions = "valid_odoo_versions"
49+
if pylint_odoo_version >= packaging.version.parse("v8.0.5"):
50+
# versions of pylint-odoo >= 8.0.5 use dashes for keys, rather than
51+
# underscores
52+
valid_odoo_versions = "valid-odoo-versions"
53+
assert f"{valid_odoo_versions}={odoo_version}" in pylintrc_mandatory
3554
assert SOME_PYLINT_OPTIONAL_CHECK not in pylintrc_mandatory
3655
pylintrc_optional = (tmp_path / ".pylintrc").read_text()
3756
assert "disable=all\n" in pylintrc_optional
3857
assert "# This .pylintrc contains" in pylintrc_optional
39-
assert f"valid_odoo_versions={odoo_version}" in pylintrc_optional
58+
assert f"{valid_odoo_versions}={odoo_version}" in pylintrc_optional
4059
assert SOME_PYLINT_OPTIONAL_CHECK in pylintrc_optional
4160
flake8 = (tmp_path / ".flake8").read_text()
4261
assert "[flake8]" in flake8

0 commit comments

Comments
 (0)