Skip to content
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

[FIX] pylint_odoo: Fix parsing dictionary from manifest #510

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

moylop260
Copy link
Collaborator

@moylop260 moylop260 commented Dec 19, 2024

The following code:

  • {"key": "" or ""}

It is parsed correctly the node code

But ast.literal_eval shows the following traceback:

Exception on node <Dict.dict l.3 at 0x10ef6aba0>
Traceback (most recent call last):
  File "pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
    ~~~~~~~~^^^^^^^^^
  File "pylint_odoo/checkers/odoo_addons.py", line 1034, in visit_dict
    manifest_dict = ast.literal_eval(node.as_string())
  File "3.13/lib/python3.13/ast.py", line 114, in literal_eval
    return _convert(node_or_string)
  File "3.13/lib/python3.13/ast.py", line 103, in _convert
    return dict(zip(map(_convert, node.keys),
                    map(_convert, node.values)))
  File "3.13/lib/python3.13/ast.py", line 113, in _convert
    return _convert_signed_num(node)
  File "3.13/lib/python3.13/ast.py", line 87, in _convert_signed_num
    return _convert_num(node)
  File "3.13/lib/python3.13/ast.py", line 78, in _convert_num
    _raise_malformed_node(node)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "3.13/lib/python3.13/ast.py", line 75, in _raise_malformed_node
    raise ValueError(msg + f': {node!r}')
ValueError: malformed node or string on line 1: <ast.BoolOp object at 0x1104df790>

@moylop260 moylop260 self-assigned this Dec 19, 2024
The following code:
 - `# e.g. {"key": "" or ""}`

It is parsed correctly the node code

But `ast.literal_eval` shows the following traceback:

```txt
Exception on node <Dict.dict l.3 at 0x10ef6aba0>
Traceback (most recent call last):
  File "pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
    ~~~~~~~~^^^^^^^^^
  File "pylint_odoo/checkers/odoo_addons.py", line 1034, in visit_dict
    manifest_dict = ast.literal_eval(node.as_string())
  File "3.13/lib/python3.13/ast.py", line 114, in literal_eval
    return _convert(node_or_string)
  File "3.13/lib/python3.13/ast.py", line 103, in _convert
    return dict(zip(map(_convert, node.keys),
                    map(_convert, node.values)))
  File "3.13/lib/python3.13/ast.py", line 113, in _convert
    return _convert_signed_num(node)
  File "3.13/lib/python3.13/ast.py", line 87, in _convert_signed_num
    return _convert_num(node)
  File "3.13/lib/python3.13/ast.py", line 78, in _convert_num
    _raise_malformed_node(node)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "3.13/lib/python3.13/ast.py", line 75, in _raise_malformed_node
    raise ValueError(msg + f': {node!r}')
ValueError: malformed node or string on line 1: <ast.BoolOp object at 0x1104df790>
````
@moylop260 moylop260 merged commit 03aa3e4 into OCA:main Dec 19, 2024
24 checks passed
@moylop260 moylop260 deleted the fix-dict-parser-moy branch December 19, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant