-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Tighten valid module version check #152
Comments
We have a guideline from CONTRIBUTING.md#idioms:
And we had issues related with this method in the past related with: E.g. OCA/manufacture#146 Maybe for pylint is not a real issue but we prefer to follow the same odoo guidelines here too. What is the wrong with binop (%) vs format here? |
I have created the following fix: #153 |
The problem is that the pylint-odoo/pylint_odoo/checkers/no_modules.py Lines 658 to 660 in a14ddca
|
…t manifest version format Issue OCA#152
* [FIX] manifest-version-format: Use real dot from regex - Fix #152 - Use str.format method instead of interpolation. Because pylint use magical interpolation feature from https://docs.python.org/2/library/configparser.html#ConfigParser.ConfigParser * [REF] manifest-version-format: Use intermediate variables in order to avoid nested methods
Currently, the following module versions will be considered as valid by pylint-odoo when using default configuration:
10+0.1.0.0
, because the dot fromvalid_odoo_versions
is not escaped when building the valid module version pattern (and the.
inside a regex matches any character other than a newline):pylint-odoo/pylint_odoo/checkers/no_modules.py
Lines 657 to 661 in a14ddca
10.0.1.0.0WHATEVER
, becausere.match
is used insideformatversion()
, which matches the string from the beginning, however, there is no$
at the end of the default value formanifest_version_format
to match the end of the string:pylint-odoo/pylint_odoo/checkers/no_modules.py
Line 237 in a14ddca
Thus, anything can follow once the version is matched from the beginning of the string.
I have started working on a fix, however, I have stumbled into a slight problem for which I need feedback from the authors - if a .pylintrc file is used with
manifest_version_format
defined inside it using the%(valid_odoo_versions)s
placeholder, thenmanifest_version_format
will be set automatically byConfigParser
(which pylint uses for configuration parsing) due to interpolation. This means that at the point when themanifest_version_format_parsed
string is built:pylint-odoo/pylint_odoo/checkers/no_modules.py
Lines 657 to 661 in a14ddca
then
self.config.manifest_version_format
no longer contains the%(valid_odoo_versions)s
placeholder, as it was already formatted byConfigParser
. This becomes a problem if we want to escape the dots fromvalid_odoo_versions
(eg.10.0
->10\.0
) insideformatversion()
, as our values will be simply ignored if a config file is used withmanifest_version_format
defined inside it using the%(valid_odoo_versions)s
placeholder.I have comeup with one solution - switch to
str.format()
style formatting formanifest_version_format
in the config, which would allow to avoid interpolation byConfigParser
. However, I guess it would be a breaking change. So my question is - would it be ok?Maybe someone has other suggestions?
The text was updated successfully, but these errors were encountered: