MCPcopy Index your code
hub / github.com/python/mypy / Parameters

Class Parameters

mypy/types.py:1909–2129  ·  view source on GitHub ↗

Type that represents the parameters to a function. Used for ParamSpec analysis. Note that by convention we handle this type as a Callable without return type, not as a "tuple with names", so that it behaves contravariantly, in particular [x: int] <: [int].

Source from the content-addressed store, hash-verified

1907
1908
1909class Parameters(ProperType):
1910 """Type that represents the parameters to a function.
1911
1912 Used for ParamSpec analysis. Note that by convention we handle this
1913 type as a Callable without return type, not as a "tuple with names",
1914 so that it behaves contravariantly, in particular [x: int] <: [int].
1915 """
1916
1917 __slots__ = (
1918 "arg_types",
1919 "arg_kinds",
1920 "arg_names",
1921 "min_args",
1922 "is_ellipsis_args",
1923 # TODO: variables don't really belong here, but they are used to allow hacky support
1924 # for forall . Foo[[x: T], T] by capturing generic callable with ParamSpec, see #15909
1925 "variables",
1926 "imprecise_arg_kinds",
1927 )
1928
1929 def __init__(
1930 self,
1931 arg_types: Sequence[Type],
1932 arg_kinds: list[ArgKind],
1933 arg_names: Sequence[str | None],
1934 *,
1935 variables: Sequence[TypeVarLikeType] | None = None,
1936 is_ellipsis_args: bool = False,
1937 imprecise_arg_kinds: bool = False,
1938 line: int = -1,
1939 column: int = -1,
1940 ) -> None:
1941 super().__init__(line, column)
1942 self.arg_types = list(arg_types)
1943 self.arg_kinds = arg_kinds
1944 self.arg_names = list(arg_names)
1945 assert len(arg_types) == len(arg_kinds) == len(arg_names)
1946 assert not any(isinstance(t, Parameters) for t in arg_types)
1947 self.min_args = arg_kinds.count(ARG_POS)
1948 self.is_ellipsis_args = is_ellipsis_args
1949 self.variables = variables or []
1950 self.imprecise_arg_kinds = imprecise_arg_kinds
1951
1952 def copy_modified(
1953 self,
1954 arg_types: Bogus[Sequence[Type]] = _dummy,
1955 arg_kinds: Bogus[list[ArgKind]] = _dummy,
1956 arg_names: Bogus[Sequence[str | None]] = _dummy,
1957 *,
1958 variables: Bogus[Sequence[TypeVarLikeType]] = _dummy,
1959 is_ellipsis_args: Bogus[bool] = _dummy,
1960 imprecise_arg_kinds: Bogus[bool] = _dummy,
1961 ) -> Parameters:
1962 return Parameters(
1963 arg_types=arg_types if arg_types is not _dummy else self.arg_types,
1964 arg_kinds=arg_kinds if arg_kinds is not _dummy else self.arg_kinds,
1965 arg_names=arg_names if arg_names is not _dummy else self.arg_names,
1966 is_ellipsis_args=(

Callers 15

pack_paramspec_argsMethod · 0.90
visit_type_listMethod · 0.90
visit_ellipsis_typeMethod · 0.90
visit_param_specMethod · 0.90
visit_callable_typeMethod · 0.90
collect_varsMethod · 0.90
visit_instanceMethod · 0.90
visit_callable_typeMethod · 0.90
visit_parametersMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…