Andrew Achkar

    2 weeks ago
    Hi Flyte team, I noticed a strange error when attempting to run
    on a python module contains
    which is used in specifying a
    . Details in 🧵
    All that’s needed to reproduce this is a file containing:
    from typing import TypeVar
    _ = TypeVar("tar.gz")
    Then run pylint on this file. I get a stacktrace like:
    ************* Module example C0114: Missing module docstring (missing-module-docstring)
    Exception on node <AssignName._ l.3 at 0x7fe8c7586580> in file '/directory/'
    Traceback (most recent call last):
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 37, in _inference_tip_cached
        result = _cache[func, node]
    KeyError: (<function infer_typing_typevar_or_newtype at 0x7fe8c6442670>, <Call l.3 at 0x7fe8c7586640>)
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 168, in _data_build
        node, parser_module = _parse_string(data, type_comments=True)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 454, in _parse_string
        parsed = parser_module.parse(data + "\n", type_comments=type_comments)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 49, in parse
        return parse_func(string)
      File "/usr/local/lib/python3.8/", line 47, in parse
        return compile(source, filename, mode, flags,
      File "<unknown>", line 10
        class tar.gz(metaclass=Meta):
    SyntaxError: invalid syntax
    The above exception was the direct cause of the following exception:
    Traceback (most recent call last):
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/pylint/checkers/", line 1258, in safe_infer
        value = next(infer_gen)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/nodes/", line 158, in infer
        results = list(self._explicit_inference(self, context, **kwargs))
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 44, in _inference_tip_cached
        result = _cache[func, node] = list(func(*args, **kwargs))
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/brain/", line 127, in infer_typing_typevar_or_newtype
        node = extract_node(TYPING_TYPE_TEMPLATE.format(typename))
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 423, in extract_node
        tree = parse(code, module_name=module_name)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 281, in parse
        return builder.string_build(code, modname=module_name, path=path)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 138, in string_build
        module, builder = self._data_build(data, modname, path)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/astroid/", line 170, in _data_build
        raise AstroidSyntaxError(
    astroid.exceptions.AstroidSyntaxError: Parsing Python code failed:
    invalid syntax (<unknown>, line 10)
    The above exception was the direct cause of the following exception:
    Traceback (most recent call last):
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/pylint/utils/", line 90, in walk
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/pylint/checkers/base/name_checker/", line 411, in visit_assignname
        inferred_assign_type = utils.safe_infer(assign_type.value)
      File "/usr/local/venvs/test-venv/lib/python3.8/site-packages/pylint/checkers/", line 1262, in safe_infer
        raise AstroidError from e
    astroid.exceptions.AstroidError F0002: Fatal error while checking ''. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/home/vscode/.cache/pylint/pylint-crash-2022-09-12-15.txt'. (astroid-error)
    AFAICT, nothing prevents creating a TypeVar with a period in the name, however, I believe it is implied that the name should be the name of a class, which cannot contain a period.
    I think that’s what tripping up pylint.
    If I understand correctly this name is really not serving any functional purpose, but it is declaring/documenting the extension of the file. It seems a bit problematic to use TypeVar in this way, in the case of having multiple extension parts.
    Eduardo Apolinario (eapolinario)

    Eduardo Apolinario (eapolinario)

    2 weeks ago
    @Andrew Achkar, thanks for the report. I opened to track this issue. It should be a simple fix.