(self, e: Call)
| 1951 | return [self.visit(e) for e in l] |
| 1952 | |
| 1953 | def visit_Call(self, e: Call) -> Type: |
| 1954 | # Parse the arg constructor |
| 1955 | f = e.func |
| 1956 | constructor = stringify_name(f) |
| 1957 | |
| 1958 | if not isinstance(self.parent(), ast3.List): |
| 1959 | note = None |
| 1960 | if constructor: |
| 1961 | if e.keywords: |
| 1962 | note = "Cannot use a function call in a type annotation" |
| 1963 | else: |
| 1964 | note = "Suggestion: use {0}[...] instead of {0}(...)".format(constructor) |
| 1965 | return self.invalid_type(e, note=note) |
| 1966 | if not constructor: |
| 1967 | self.fail(message_registry.ARG_CONSTRUCTOR_NAME_EXPECTED, e.lineno, e.col_offset) |
| 1968 | |
| 1969 | name: str | None = None |
| 1970 | default_type = AnyType(TypeOfAny.special_form) |
| 1971 | typ: Type = default_type |
| 1972 | for i, arg in enumerate(e.args): |
| 1973 | if i == 0: |
| 1974 | converted = self.visit(arg) |
| 1975 | assert converted is not None |
| 1976 | typ = converted |
| 1977 | elif i == 1: |
| 1978 | name = self._extract_argument_name(arg) |
| 1979 | else: |
| 1980 | self.fail(message_registry.ARG_CONSTRUCTOR_TOO_MANY_ARGS, f.lineno, f.col_offset) |
| 1981 | for k in e.keywords: |
| 1982 | value = k.value |
| 1983 | if k.arg == "name": |
| 1984 | if name is not None: |
| 1985 | self.fail( |
| 1986 | message_registry.MULTIPLE_VALUES_FOR_NAME_KWARG.format(constructor), |
| 1987 | f.lineno, |
| 1988 | f.col_offset, |
| 1989 | ) |
| 1990 | name = self._extract_argument_name(value) |
| 1991 | elif k.arg == "type": |
| 1992 | if typ is not default_type: |
| 1993 | self.fail( |
| 1994 | message_registry.MULTIPLE_VALUES_FOR_TYPE_KWARG.format(constructor), |
| 1995 | f.lineno, |
| 1996 | f.col_offset, |
| 1997 | ) |
| 1998 | converted = self.visit(value) |
| 1999 | assert converted is not None |
| 2000 | typ = converted |
| 2001 | else: |
| 2002 | self.fail( |
| 2003 | message_registry.ARG_CONSTRUCTOR_UNEXPECTED_ARG.format(k.arg), |
| 2004 | value.lineno, |
| 2005 | value.col_offset, |
| 2006 | ) |
| 2007 | return CallableArgument(typ, name, constructor, e.lineno, e.col_offset) |
| 2008 | |
| 2009 | def translate_argument_list(self, l: Sequence[ast3.expr]) -> TypeList: |
| 2010 | return TypeList([self.visit(e) for e in l], line=self.line) |
nothing calls this directly
no test coverage detected