-
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
pylint-dev/astroid
#2024Labels
AstroidRelated to astroidRelated to astroidCrash 💥A bug that makes pylint crashA bug that makes pylint crashNeeds astroid updateNeeds an astroid update (probably a release too) before being mergableNeeds an astroid update (probably a release too) before being mergable
Milestone
Description
Bug description
pylint failed with Fatal error but code is working
# number.py from dataclasses import dataclass @dataclass class Number: amount: int | float round: int = 2 def __str__(self): number_format = "{:,.%sf}" % self.round return number_format.format(self.amount).rstrip("0").rstrip(".")Command used
pylint number.pyPylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace: Traceback (most recent call last): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/inference_tip.py", line 38, in _inference_tip_cached result = _cache[func, node] ~~~~~~^^^^^^^^^^^^ KeyError: (<function _infer_str_format_call at 0x1056fb6a0>, <Call l.11 at 0x107c0e250>) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 790, in _lint_file check_astroid_module(module) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1060, in check_astroid_module retval = self._check_astroid_module( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1110, in _check_astroid_module walker.walk(node) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 93, in walk self.walk(child) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 93, in walk self.walk(child) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 90, in walk callback(astroid) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/checkers/classes/special_methods_checker.py", line 183, in visit_functiondef inferred = _safe_infer_call_result(node, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/checkers/classes/special_methods_checker.py", line 42, in _safe_infer_call_result value = next(inferit) ^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1749, in infer_call_result yield from returnnode.value.infer(context) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 169, in infer yield from self._infer(context=context, **kwargs) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 140, in raise_if_nothing_inferred yield next(generator) ^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 109, in wrapped for res in _func(node, context, **kwargs): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/inference.py", line 256, in infer_call for callee in self.func.infer(context): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 182, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 140, in raise_if_nothing_inferred yield next(generator) ^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 109, in wrapped for res in _func(node, context, **kwargs): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/inference.py", line 344, in infer_attribute for owner in self.expr.infer(context): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 182, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 140, in raise_if_nothing_inferred yield next(generator) ^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 109, in wrapped for res in _func(node, context, **kwargs): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/inference.py", line 256, in infer_call for callee in self.func.infer(context): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 182, in infer for i, result in enumerate(self._infer(context=context, **kwargs)): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 140, in raise_if_nothing_inferred yield next(generator) ^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/decorators.py", line 109, in wrapped for res in _func(node, context, **kwargs): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/inference.py", line 344, in infer_attribute for owner in self.expr.infer(context): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/nodes/node_ng.py", line 159, in infer results = list(self._explicit_inference(self, context, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/inference_tip.py", line 45, in _inference_tip_cached result = _cache[func, node] = list(func(*args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/astroid/brain/brain_builtin_inference.py", line 937, in _infer_str_format_call format_template = value.value ^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'value' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 755, in _lint_files self._lint_file(fileitem, module, check_astroid_module) File "/Users/siner308/Library/Caches/pypoetry/virtualenvs/myproject-6nZamvkJ-py3.11/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 792, in _lint_file raise astroid.AstroidError from e astroid.exceptions.AstroidErrorExpected behavior
pass pylint Pylint version
pylint 2.15.6 astroid 2.12.13 Python 3.11.0 (main, Nov 30 2022, 12:30:30) [Clang 14.0.0 (clang-1400.0.29.202)]Metadata
Metadata
Assignees
Labels
AstroidRelated to astroidRelated to astroidCrash 💥A bug that makes pylint crashA bug that makes pylint crashNeeds astroid updateNeeds an astroid update (probably a release too) before being mergableNeeds an astroid update (probably a release too) before being mergable