Skip to content

Commit aa5207f

Browse files
committed
[REF] website-manifest-key-not-valid-uri: Remove dependency to validators
Adding the same regex to validate URL
1 parent a203775 commit aa5207f

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ translation-too-few-args | Not enough arguments for odoo._ format string | E8306
7070
translation-too-many-args | Too many arguments for odoo._ format string | E8305
7171
translation-unsupported-format | Unsupported odoo._ format character %r (%#02x) at index %d | E8300
7272
use-vim-comment | Use of vim comment | W8202
73-
website-manifest-key-not-valid-uri | Website "%s" in manifest key is not a valid URI | W8114
73+
website-manifest-key-not-valid-uri | Website "%s" in manifest key is not a valid URI. %s | W8114
7474

7575

7676
[//]: # (end-checks)
@@ -394,7 +394,8 @@ Checks valid only for odoo <= 13.0
394394

395395
* website-manifest-key-not-valid-uri
396396

397-
- https://github.com/OCA/pylint-odoo/blob/v9.3.1/testing/resources/test_repo/broken_module3/__openerp__.py#L7 Website "htt://odoo-community.com" in manifest key is not a valid URI
397+
- https://github.com/OCA/pylint-odoo/blob/v9.3.1/testing/resources/test_repo/broken_module2/__openerp__.py#L7 Website "https://odoo-community.org,https://odoo.com" in manifest key is not a valid URI. Domain 'odoo-community.org,https:' contains invalid characters
398+
- https://github.com/OCA/pylint-odoo/blob/v9.3.1/testing/resources/test_repo/broken_module3/__openerp__.py#L7 Website "htt://odoo-community.com" in manifest key is not a valid URI. URL needs to start with 'http[s]://'
398399

399400
[//]: # (end-example)
400401

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pylint-plugin-utils==0.8.*
22
pylint==3.3.*
3-
validators==0.34.*

src/pylint_odoo/checkers/odoo_addons.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
import string
105105
from collections import Counter, defaultdict
106106

107-
import validators
108107
from astroid import ClassDef, FunctionDef, NodeNG, nodes
109108
from pylint.checkers import BaseChecker, utils
110109
from pylint.lint import PyLinter
@@ -217,7 +216,7 @@
217216
CHECK_DESCRIPTION,
218217
),
219218
"W8114": (
220-
'Website "%s" in manifest key is not a valid URI',
219+
'Website "%s" in manifest key is not a valid URI. %s',
221220
"website-manifest-key-not-valid-uri",
222221
CHECK_DESCRIPTION,
223222
),
@@ -1157,11 +1156,18 @@ def visit_dict(self, node):
11571156
self.add_message("missing-readme", args=(self.linter.config.readme_template_url,), node=node)
11581157

11591158
# Check if the website is valid URI
1160-
website = manifest_dict.get("website", "")
1161-
url_is_valid = bool(validators.url(website))
1162-
if website and "," not in website and not url_is_valid:
1159+
website = manifest_dict.get("website") or ""
1160+
msg = ""
1161+
url_is_valid = False
1162+
try:
1163+
url_is_valid = misc.validate_url(website)
1164+
except misc.InvalidURL as url_exc:
1165+
msg = str(url_exc)
1166+
if website and not url_is_valid:
11631167
self.add_message(
1164-
"website-manifest-key-not-valid-uri", node=manifest_keys_nodes.get("website") or node, args=(website)
1168+
"website-manifest-key-not-valid-uri",
1169+
node=manifest_keys_nodes.get("website") or node,
1170+
args=(website, msg),
11651171
)
11661172

11671173
# Check valid development_status values

src/pylint_odoo/misc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
2+
import re
23
import subprocess
34
import sys
45
from contextlib import contextmanager
56
from functools import lru_cache
67
from pathlib import Path
8+
from urllib.parse import urlsplit
79

810
MANIFEST_DATA_KEYS = ["data", "demo", "demo_xml", "init_xml", "test", "update_xml"]
911

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"translation-too-many-args": 2,
6666
"translation-unsupported-format": 2,
6767
"use-vim-comment": 1,
68-
"website-manifest-key-not-valid-uri": 1,
68+
"website-manifest-key-not-valid-uri": 2,
6969
"no-raise-unlink": 2,
7070
"deprecated-odoo-model-method": 2,
7171
"manifest-behind-migrations": 3,

0 commit comments

Comments
 (0)