-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
AstroidSyntaxError when parsing NewType #5770
Comments
Pierre-Sassoulas
added
Crash 💥
A bug that makes pylint crash
Needs investigation 🔬
A bug or crash where it's not immediately obvious what is happenning
labels
Feb 5, 2022
Source from typing import NewType
def make_new_type(t):
new_type = NewType(f'IntRange_{t}', t)
print(new_type) Sanity check
Traceback % pylint a.py
Exception on node <Assign l.4 at 0x106b6d190> in file '/Users/.../pylint/a.py'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/inference_tip.py", line 28, in _inference_tip_cached
result = _cache[func, node]
KeyError: (<function infer_typing_typevar_or_newtype at 0x106654040>, <Call l.4 at 0x106b6d0d0>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/builder.py", line 181, in _data_build
node, parser_module = _parse_string(data, type_comments=True)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/builder.py", line 461, in _parse_string
parsed = parser_module.parse(data + "\n", type_comments=type_comments)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/_ast.py", line 45, in parse
return parse_func(string)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "<unknown>", line 10
class f'IntRange_{t}(metaclass=Meta):
^
SyntaxError: EOL while scanning string literal
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/.../pylint/pylint/utils/ast_walker.py", line 72, in walk
callback(astroid)
File "/Users/.../pylint/pylint/extensions/redefined_variable_type.py", line 110, in visit_assign
_type = node_type(node.value)
File "/Users/.../pylint/pylint/checkers/utils.py", line 1325, in node_type
for var_type in node.infer():
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 140, in infer
results = list(self._explicit_inference(self, context, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wrapt/wrappers.py", line 566, in __call__
return self._self_wrapper(self.__wrapped__, self._self_instance,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/inference_tip.py", line 30, in _inference_tip_cached
result = _cache[func, node] = list(func(*args, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/brain/brain_typing.py", line 132, in infer_typing_typevar_or_newtype
node = extract_node(TYPING_TYPE_TEMPLATE.format(typename))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/builder.py", line 438, in extract_node
tree = parse(code, module_name=module_name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/builder.py", line 296, in parse
return builder.string_build(code, modname=module_name, path=path)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/builder.py", line 155, in string_build
module = self._data_build(data, modname, path)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astroid/builder.py", line 183, in _data_build
raise AstroidSyntaxError(
astroid.exceptions.AstroidSyntaxError: Parsing Python code failed:
EOL while scanning string literal (<unknown>, line 10)
************* Module a
a.py:1:0: F0002: a.py: Fatal error while checking 'a.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Users/.../Library/Caches/pylint/pylint-crash-2022-02-18-22.txt'. (astroid-error)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00) Version
|
2 tasks
Pierre-Sassoulas
removed
the
Needs investigation 🔬
A bug or crash where it's not immediately obvious what is happenning
label
Feb 19, 2022
@jacobtylerwalls Would you be willing to already open a PR with a test for this? This is the last issue for |
jacobtylerwalls
added a commit
to jacobtylerwalls/pylint
that referenced
this issue
Feb 27, 2022
jacobtylerwalls
added a commit
that referenced
this issue
Mar 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pylint-crash-2022-02-04-15.txt
The text was updated successfully, but these errors were encountered: