id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
6,067,801 | is_forward_op_method | def is_forward_op_method(self, method_name: str) -> bool:
return method_name in operators.reverse_op_methods | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,278 | 1,279 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,802 | is_reverse_op_method | def is_reverse_op_method(self, method_name: str) -> bool:
return method_name in operators.reverse_op_method_set | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,281 | 1,282 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,803 | check_for_missing_annotations | def check_for_missing_annotations(self, fdef: FuncItem) -> None:
# Check for functions with unspecified/not fully specified types.
def is_unannotated_any(t: Type) -> bool:
if not isinstance(t, ProperType):
return False
return isinstance(t, AnyType) and t.type_of_a... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,284 | 1,325 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,804 | is_unannotated_any | def is_unannotated_any(t: Type) -> bool:
if not isinstance(t, ProperType):
return False
return isinstance(t, AnyType) and t.type_of_any == TypeOfAny.unannotated | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,286 | 1,289 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,805 | check___new___signature | def check___new___signature(self, fdef: FuncDef, typ: CallableType) -> None:
self_type = fill_typevars_with_any(fdef.info)
bound_type = bind_self(typ, self_type, is_classmethod=True)
# Check that __new__ (after binding cls) returns an instance
# type (or any).
if isinstance(fdef.... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,327 | 1,356 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,806 | check_reverse_op_method | def check_reverse_op_method(
self, defn: FuncItem, reverse_type: CallableType, reverse_name: str, context: Context
) -> None:
"""Check a reverse operator method such as __radd__."""
# Decides whether it's worth calling check_overlapping_op_methods().
# This used to check for some ve... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,358 | 1,433 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,807 | check_overlapping_op_methods | def check_overlapping_op_methods(
self,
reverse_type: CallableType,
reverse_name: str,
reverse_class: TypeInfo,
forward_type: Type,
forward_name: str,
forward_base: Type,
context: Context,
) -> None:
"""Check for overlapping method and reverse ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,435 | 1,497 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,808 | is_unsafe_overlapping_op | def is_unsafe_overlapping_op(
self, forward_item: CallableType, forward_base: Type, reverse_type: CallableType
) -> bool:
# TODO: check argument kinds?
if len(forward_item.arg_types) < 1:
# Not a valid operator method -- can't succeed anyway.
return False
# E... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,499 | 1,543 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,809 | check_inplace_operator_method | def check_inplace_operator_method(self, defn: FuncBase) -> None:
"""Check an inplace operator method such as __iadd__.
They cannot arbitrarily overlap with __add__.
"""
method = defn.name
if method not in operators.inplace_operator_methods:
return
typ = bind_... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,545 | 1,569 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,810 | check_getattr_method | def check_getattr_method(self, typ: Type, context: Context, name: str) -> None:
if len(self.scope.stack) == 1:
# module scope
if name == "__getattribute__":
self.fail(message_registry.MODULE_LEVEL_GETATTRIBUTE, context)
return
# __getattr__ is ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,571 | 1,598 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,811 | check_setattr_method | def check_setattr_method(self, typ: Type, context: Context) -> None:
if not self.scope.active_class():
return
method_type = CallableType(
[
AnyType(TypeOfAny.special_form),
self.named_type("builtins.str"),
AnyType(TypeOfAny.special_... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,600 | 1,615 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,812 | check_slots_definition | def check_slots_definition(self, typ: Type, context: Context) -> None:
"""Check the type of __slots__."""
str_type = self.named_type("builtins.str")
expected_type = UnionType(
[str_type, self.named_generic_type("typing.Iterable", [str_type])]
)
self.check_subtype(
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,617 | 1,631 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,813 | check_match_args | def check_match_args(self, var: Var, typ: Type, context: Context) -> None:
"""Check that __match_args__ contains literal strings"""
typ = get_proper_type(typ)
if not isinstance(typ, TupleType) or not all(
[is_string_literal(item) for item in typ.items]
):
self.msg... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,633 | 1,644 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,814 | expand_typevars | def expand_typevars(
self, defn: FuncItem, typ: CallableType
) -> list[tuple[FuncItem, CallableType]]:
# TODO use generator
subst: list[list[tuple[TypeVarId, Type]]] = []
tvars = list(typ.variables) or []
if defn.info:
# Class type variables
tvars += d... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,646 | 1,670 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,815 | check_method_override | def check_method_override(self, defn: FuncDef | OverloadedFuncDef | Decorator) -> None:
"""Check if function definition is compatible with base classes.
This may defer the method if a signature is not available in at least one base class.
"""
# Check against definitions in base classes.... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,672 | 1,681 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,816 | check_method_or_accessor_override_for_base | def check_method_or_accessor_override_for_base(
self, defn: FuncDef | OverloadedFuncDef | Decorator, base: TypeInfo
) -> bool:
"""Check if method definition is compatible with a base class.
Return True if the node was deferred because one of the corresponding
superclass nodes is not... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,683 | 1,716 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,817 | check_method_override_for_base_with_name | def check_method_override_for_base_with_name(
self, defn: FuncDef | OverloadedFuncDef | Decorator, name: str, base: TypeInfo
) -> bool:
"""Check if overriding an attribute `name` of `base` with `defn` is valid.
Return True if the supertype node was not analysed yet, and `defn` was deferred.... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,718 | 1,817 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,818 | bind_and_map_method | def bind_and_map_method(
self, sym: SymbolTableNode, typ: FunctionLike, sub_info: TypeInfo, super_info: TypeInfo
) -> FunctionLike:
"""Bind self-type and map type variables for a method.
Arguments:
sym: a symbol that points to method definition
typ: method type on th... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,819 | 1,840 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,819 | get_op_other_domain | def get_op_other_domain(self, tp: FunctionLike) -> Type | None:
if isinstance(tp, CallableType):
if tp.arg_kinds and tp.arg_kinds[0] == ARG_POS:
return tp.arg_types[0]
return None
elif isinstance(tp, Overloaded):
raw_items = [self.get_op_other_domain(i... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,842 | 1,854 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,820 | check_override | def check_override(
self,
override: FunctionLike,
original: FunctionLike,
name: str,
name_in_super: str,
supertype: str,
original_class_or_static: bool,
override_class_or_static: bool,
node: Context,
) -> None:
"""Check a method overrid... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,856 | 1,988 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,821 | erase_override | def erase_override(t: Type) -> Type:
return erase_typevars(t, ids_to_erase=override_ids) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,933 | 1,934 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,822 | check__exit__return_type | def check__exit__return_type(self, defn: FuncItem) -> None:
"""Generate error if the return type of __exit__ is problematic.
If __exit__ always returns False but the return type is declared
as bool, mypy thinks that a with statement may "swallow"
exceptions even though this is not the c... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 1,990 | 2,013 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,823 | visit_class_def | def visit_class_def(self, defn: ClassDef) -> None:
"""Type check a class definition."""
typ = defn.info
for base in typ.mro[1:]:
if base.is_final:
self.fail(message_registry.CANNOT_INHERIT_FROM_FINAL.format(base.name), defn)
with self.tscope.class_scope(defn.i... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,015 | 2,065 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,824 | check_final_deletable | def check_final_deletable(self, typ: TypeInfo) -> None:
# These checks are only for mypyc. Only perform some checks that are easier
# to implement here than in mypyc.
for attr in typ.deletable_attributes:
node = typ.names.get(attr)
if node and isinstance(node.node, Var) a... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,067 | 2,073 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,825 | check_init_subclass | def check_init_subclass(self, defn: ClassDef) -> None:
"""Check that keywords in a class definition are valid arguments for __init_subclass__().
In this example:
1 class Base:
2 def __init_subclass__(cls, thing: int):
3 pass
4 class Ch... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,075 | 2,121 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,826 | check_enum | def check_enum(self, defn: ClassDef) -> None:
assert defn.info.is_enum
if defn.info.fullname not in ENUM_BASES:
for sym in defn.info.names.values():
if (
isinstance(sym.node, Var)
and sym.node.has_explicit_value
and ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,123 | 2,140 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,827 | check_final_enum | def check_final_enum(self, defn: ClassDef, base: TypeInfo) -> None:
for sym in base.names.values():
if self.is_final_enum_value(sym):
self.fail(f'Cannot extend enum with existing members: "{base.name}"', defn)
break | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,142 | 2,146 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,828 | is_final_enum_value | def is_final_enum_value(self, sym: SymbolTableNode) -> bool:
if isinstance(sym.node, (FuncBase, Decorator)):
return False # A method is fine
if not isinstance(sym.node, Var):
return True # Can be a class or anything else
# Now, only `Var` is left, we need to check:
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,148 | 2,172 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,829 | check_enum_bases | def check_enum_bases(self, defn: ClassDef) -> None:
"""
Non-enum mixins cannot appear after enum bases; this is disallowed at runtime:
class Foo: ...
class Bar(enum.Enum, Foo): ...
But any number of enum mixins can appear in a class definition
(even if multiple ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,174 | 2,197 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,830 | check_enum_new | def check_enum_new(self, defn: ClassDef) -> None:
def has_new_method(info: TypeInfo) -> bool:
new_method = info.get("__new__")
return bool(
new_method
and new_method.node
and new_method.node.fullname != "builtins.object.__new__"
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,199 | 2,225 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,831 | has_new_method | def has_new_method(info: TypeInfo) -> bool:
new_method = info.get("__new__")
return bool(
new_method
and new_method.node
and new_method.node.fullname != "builtins.object.__new__"
) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,200 | 2,206 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,832 | check_protocol_variance | def check_protocol_variance(self, defn: ClassDef) -> None:
"""Check that protocol definition is compatible with declared
variances of type variables.
Note that we also prohibit declaring protocol classes as invariant
if they are actually covariant/contravariant, since this may break
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,227 | 2,256 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,833 | check_multiple_inheritance | def check_multiple_inheritance(self, typ: TypeInfo) -> None:
"""Check for multiple inheritance related errors."""
if len(typ.bases) <= 1:
# No multiple inheritance.
return
# Verify that inherited attributes are compatible.
mro = typ.mro[1:]
for i, base in ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,258 | 2,277 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,834 | determine_type_of_class_member | def determine_type_of_class_member(self, sym: SymbolTableNode) -> Type | None:
if sym.type is not None:
return sym.type
if isinstance(sym.node, FuncBase):
return self.function_type(sym.node)
if isinstance(sym.node, TypeInfo):
# nested class
return ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,279 | 2,291 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,835 | check_compatibility | def check_compatibility(
self, name: str, base1: TypeInfo, base2: TypeInfo, ctx: TypeInfo
) -> None:
"""Check if attribute name in base1 is compatible with base2 in multiple inheritance.
Assume base1 comes before base2 in the MRO, and that base1 and base2 don't have
a direct subclas... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,293 | 2,360 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,836 | visit_import_from | def visit_import_from(self, node: ImportFrom) -> None:
self.check_import(node) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,362 | 2,363 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,837 | visit_import_all | def visit_import_all(self, node: ImportAll) -> None:
self.check_import(node) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,365 | 2,366 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,838 | visit_import | def visit_import(self, s: Import) -> None:
pass | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,368 | 2,369 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,839 | check_import | def check_import(self, node: ImportBase) -> None:
for assign in node.assignments:
lvalue = assign.lvalues[0]
lvalue_type, _, __ = self.check_lvalue(lvalue)
if lvalue_type is None:
# TODO: This is broken.
lvalue_type = AnyType(TypeOfAny.special_... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,371 | 2,388 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,840 | visit_block | def visit_block(self, b: Block) -> None:
if b.is_unreachable:
# This block was marked as being unreachable during semantic analysis.
# It turns out any blocks marked in this way are *intentionally* marked
# as unreachable -- so we don't display an error.
self.bind... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,394 | 2,406 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,841 | should_report_unreachable_issues | def should_report_unreachable_issues(self) -> bool:
return (
self.in_checked_function()
and self.options.warn_unreachable
and not self.binder.is_unreachable_warning_suppressed()
) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,408 | 2,413 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,842 | is_raising_or_empty | def is_raising_or_empty(self, s: Statement) -> bool:
"""Returns 'true' if the given statement either throws an error of some kind
or is a no-op.
We use this function mostly while handling the '--warn-unreachable' flag. When
that flag is present, we normally report an error on any unreac... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,415 | 2,441 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,843 | visit_assignment_stmt | def visit_assignment_stmt(self, s: AssignmentStmt) -> None:
"""Type check an assignment statement.
Handle all kinds of assignment statements (simple, indexed, multiple).
"""
# Avoid type checking type aliases in stubs to avoid false
# positives about modern type syntax available... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,443 | 2,490 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,844 | check_type_alias_rvalue | def check_type_alias_rvalue(self, s: AssignmentStmt) -> None:
if not (self.is_stub and isinstance(s.rvalue, OpExpr) and s.rvalue.op == "|"):
# We do this mostly for compatibility with old semantic analyzer.
# TODO: should we get rid of this?
alias_type = self.expr_checker.acc... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,492 | 2,513 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,845 | accept_items | def accept_items(e: Expression) -> None:
if isinstance(e, OpExpr) and e.op == "|":
accept_items(e.left)
accept_items(e.right)
else:
# Nested union types have been converted to type context
# in semantic analy... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,502 | 2,510 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,846 | check_assignment | def check_assignment(
self,
lvalue: Lvalue,
rvalue: Expression,
infer_lvalue_type: bool = True,
new_syntax: bool = False,
) -> None:
"""Type check a single assignment: lvalue = rvalue."""
if isinstance(lvalue, TupleExpr) or isinstance(lvalue, ListExpr):
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,515 | 2,681 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,847 | try_infer_partial_generic_type_from_assignment | def try_infer_partial_generic_type_from_assignment(
self, lvalue: Lvalue, rvalue: Expression, op: str
) -> None:
"""Try to infer a precise type for partial generic type from assignment.
'op' is '=' for normal assignment and a binary operator ('+', ...) for
augmented assignment.
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,686 | 2,730 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,848 | check_compatibility_all_supers | def check_compatibility_all_supers(
self, lvalue: RefExpr, lvalue_type: Type | None, rvalue: Expression
) -> bool:
lvalue_node = lvalue.node
# Check if we are a class variable with at least one base class
if (
isinstance(lvalue_node, Var)
and lvalue.kind in (M... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,732 | 2,787 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,849 | check_compatibility_super | def check_compatibility_super(
self,
lvalue: RefExpr,
lvalue_type: Type | None,
rvalue: Expression,
base: TypeInfo,
base_type: Type,
base_node: Node,
) -> bool:
lvalue_node = lvalue.node
assert isinstance(lvalue_node, Var)
# Do not che... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,789 | 2,853 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,850 | lvalue_type_from_base | def lvalue_type_from_base(
self, expr_node: Var, base: TypeInfo
) -> tuple[Type | None, Node | None]:
"""For a NameExpr that is part of a class, walk all base classes and try
to find the first class that defines a Type for the same name."""
expr_name = expr_node.name
base_var... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,855 | 2,896 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,851 | check_compatibility_classvar_super | def check_compatibility_classvar_super(
self, node: Var, base: TypeInfo, base_node: Node | None
) -> bool:
if not isinstance(base_node, Var):
return True
if node.is_classvar and not base_node.is_classvar:
self.fail(message_registry.CANNOT_OVERRIDE_INSTANCE_VAR.format(... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,898 | 2,909 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,852 | check_compatibility_final_super | def check_compatibility_final_super(
self, node: Var, base: TypeInfo, base_node: Node | None
) -> bool:
"""Check if an assignment overrides a final attribute in a base class.
This only checks situations where either a node in base class is not a variable
but a final method, or where... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,911 | 2,936 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,853 | check_if_final_var_override_writable | def check_if_final_var_override_writable(
self, name: str, base_node: Node | None, ctx: Context
) -> None:
"""Check that a final variable doesn't override writeable attribute.
This is done to prevent situations like this:
class C:
attr = 1
class D(C):... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,938 | 2,956 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,854 | get_final_context | def get_final_context(self) -> bool:
"""Check whether we a currently checking a final declaration."""
return self._is_final_def | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,958 | 2,960 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,855 | enter_final_context | def enter_final_context(self, is_final_def: bool) -> Iterator[None]:
"""Store whether the current checked assignment is a final declaration."""
old_ctx = self._is_final_def
self._is_final_def = is_final_def
try:
yield
finally:
self._is_final_def = old_ctx | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,963 | 2,970 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,856 | check_final | def check_final(self, s: AssignmentStmt | OperatorAssignmentStmt | AssignmentExpr) -> None:
"""Check if this assignment does not assign to a final attribute.
This function performs the check only for name assignments at module
and class scope. The assignments to `obj.attr` and `Cls.attr` are ch... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 2,972 | 3,021 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,857 | check_assignment_to_slots | def check_assignment_to_slots(self, lvalue: Lvalue) -> None:
if not isinstance(lvalue, MemberExpr):
return
inst = get_proper_type(self.expr_checker.accept(lvalue.expr))
if not isinstance(inst, Instance):
return
if inst.type.slots is None:
return # Sl... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,023 | 3,052 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,858 | is_assignable_slot | def is_assignable_slot(self, lvalue: Lvalue, typ: Type | None) -> bool:
if getattr(lvalue, "node", None):
return False # This is a definition
typ = get_proper_type(typ)
if typ is None or isinstance(typ, AnyType):
return True # Any can be literally anything, like `@prop... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,054 | 3,071 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,859 | check_assignment_to_multiple_lvalues | def check_assignment_to_multiple_lvalues(
self,
lvalues: list[Lvalue],
rvalue: Expression,
context: Context,
infer_lvalue_type: bool = True,
) -> None:
if isinstance(rvalue, TupleExpr) or isinstance(rvalue, ListExpr):
# Recursively go into Tuple or List ex... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,073 | 3,157 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,860 | check_rvalue_count_in_assignment | def check_rvalue_count_in_assignment(
self, lvalues: list[Lvalue], rvalue_count: int, context: Context
) -> bool:
if any(isinstance(lvalue, StarExpr) for lvalue in lvalues):
if len(lvalues) - 1 > rvalue_count:
self.msg.wrong_number_values_to_unpack(rvalue_count, len(lvalu... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,159 | 3,169 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,861 | check_multi_assignment | def check_multi_assignment(
self,
lvalues: list[Lvalue],
rvalue: Expression,
context: Context,
infer_lvalue_type: bool = True,
rv_type: Type | None = None,
undefined_rvalue: bool = False,
) -> None:
"""Check the assignment of one rvalue to a number of ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,171 | 3,216 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,862 | check_multi_assignment_from_union | def check_multi_assignment_from_union(
self,
lvalues: list[Expression],
rvalue: Expression,
rvalue_type: UnionType,
context: Context,
infer_lvalue_type: bool,
) -> None:
"""Check assignment to multiple lvalue targets when rvalue type is a Union[...].
F... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,218 | 3,285 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,863 | flatten_lvalues | def flatten_lvalues(self, lvalues: list[Expression]) -> list[Expression]:
res: list[Expression] = []
for lv in lvalues:
if isinstance(lv, (TupleExpr, ListExpr)):
res.extend(self.flatten_lvalues(lv.items))
if isinstance(lv, StarExpr):
# Unwrap StarE... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,287 | 3,296 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,864 | check_multi_assignment_from_tuple | def check_multi_assignment_from_tuple(
self,
lvalues: list[Lvalue],
rvalue: Expression,
rvalue_type: TupleType,
context: Context,
undefined_rvalue: bool,
infer_lvalue_type: bool = True,
) -> None:
if self.check_rvalue_count_in_assignment(lvalues, len(r... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,298 | 3,357 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,865 | lvalue_type_for_inference | def lvalue_type_for_inference(self, lvalues: list[Lvalue], rvalue_type: TupleType) -> Type:
star_index = next(
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)), len(lvalues)
)
left_lvs = lvalues[:star_index]
star_lv = cast(StarExpr, lvalues[star_index]) if star... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,359 | 3,395 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,866 | append_types_for_inference | def append_types_for_inference(lvs: list[Expression], rv_types: list[Type]) -> None:
for lv, rv_type in zip(lvs, rv_types):
sub_lvalue_type, index_expr, inferred = self.check_lvalue(lv)
if sub_lvalue_type and not isinstance(sub_lvalue_type, PartialType):
t... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,372 | 3,380 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,867 | split_around_star | def split_around_star(
self, items: list[T], star_index: int, length: int
) -> tuple[list[T], list[T], list[T]]:
"""Splits a list of items in three to match another list of length 'length'
that contains a starred expression at 'star_index' in the following way:
star_index = 2, lengt... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,397 | 3,411 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,868 | type_is_iterable | def type_is_iterable(self, type: Type) -> bool:
type = get_proper_type(type)
if isinstance(type, CallableType) and type.is_type_obj():
type = type.fallback
return is_subtype(
type, self.named_generic_type("typing.Iterable", [AnyType(TypeOfAny.special_form)])
) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,413 | 3,419 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,869 | check_multi_assignment_from_iterable | def check_multi_assignment_from_iterable(
self,
lvalues: list[Lvalue],
rvalue_type: Type,
context: Context,
infer_lvalue_type: bool = True,
) -> None:
rvalue_type = get_proper_type(rvalue_type)
if self.type_is_iterable(rvalue_type) and isinstance(rvalue_type, ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,421 | 3,442 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,870 | check_lvalue | def check_lvalue(self, lvalue: Lvalue) -> tuple[Type | None, IndexExpr | None, Var | None]:
lvalue_type = None
index_lvalue = None
inferred = None
if self.is_definition(lvalue) and (
not isinstance(lvalue, NameExpr) or isinstance(lvalue.node, Var)
):
if i... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,444 | 3,482 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,871 | is_definition | def is_definition(self, s: Lvalue) -> bool:
if isinstance(s, NameExpr):
if s.is_inferred_def:
return True
# If the node type is not defined, this must the first assignment
# that we process => this is a definition, even though the semantic
# analyz... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,484 | 3,498 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,872 | infer_variable_type | def infer_variable_type(
self, name: Var, lvalue: Lvalue, init_type: Type, context: Context
) -> None:
"""Infer the type of initialized variables from initializer type."""
if isinstance(init_type, DeletedType):
self.msg.deleted_as_rvalue(init_type, context)
elif not is_va... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,500 | 3,530 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,873 | infer_partial_type | def infer_partial_type(self, name: Var, lvalue: Lvalue, init_type: Type) -> bool:
init_type = get_proper_type(init_type)
if isinstance(init_type, NoneType):
partial_type = PartialType(None, name)
elif isinstance(init_type, Instance):
fullname = init_type.type.fullname
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,532 | 3,570 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,874 | is_valid_defaultdict_partial_value_type | def is_valid_defaultdict_partial_value_type(self, t: ProperType) -> bool:
"""Check if t can be used as the basis for a partial defaultdict value type.
Examples:
* t is 'int' --> True
* t is 'list[<nothing>]' --> True
* t is 'dict[...]' --> False (only generic types with a... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,572 | 3,594 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,875 | set_inferred_type | def set_inferred_type(self, var: Var, lvalue: Lvalue, type: Type) -> None:
"""Store inferred variable type.
Store the type to both the variable node and the expression node that
refers to the variable (lvalue). If var is None, do nothing.
"""
if var and not self.current_node_def... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,596 | 3,612 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,876 | set_inference_error_fallback_type | def set_inference_error_fallback_type(self, var: Var, lvalue: Lvalue, type: Type) -> None:
"""Store best known type for variable if type inference failed.
If a program ignores error on type inference error, the variable should get some
inferred type so that if can used later on in the program. ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,614 | 3,626 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,877 | inference_error_fallback_type | def inference_error_fallback_type(self, type: Type) -> Type:
fallback = type.accept(SetNothingToAny())
# Type variables may leak from inference, see https://github.com/python/mypy/issues/5738,
# we therefore need to erase them.
return erase_typevars(fallback) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,628 | 3,632 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,878 | check_simple_assignment | def check_simple_assignment(
self,
lvalue_type: Type | None,
rvalue: Expression,
context: Context,
msg: str = message_registry.INCOMPATIBLE_TYPES_IN_ASSIGNMENT,
lvalue_name: str = "variable",
rvalue_name: str = "expression",
*,
code: ErrorCode | No... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,634 | 3,670 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,879 | check_member_assignment | def check_member_assignment(
self, instance_type: Type, attribute_type: Type, rvalue: Expression, context: Context
) -> tuple[Type, Type, bool]:
"""Type member assignment.
This defers to check_simple_assignment, unless the member expression
is a descriptor, in which case this checks... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,672 | 3,793 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,880 | check_indexed_assignment | def check_indexed_assignment(
self, lvalue: IndexExpr, rvalue: Expression, context: Context
) -> None:
"""Type check indexed assignment base[index] = rvalue.
The lvalue argument is the base[index] expression.
"""
self.try_infer_partial_type_from_indexed_assignment(lvalue, rv... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,795 | 3,816 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,881 | try_infer_partial_type_from_indexed_assignment | def try_infer_partial_type_from_indexed_assignment(
self, lvalue: IndexExpr, rvalue: Expression
) -> None:
# TODO: Should we share some of this with try_infer_partial_type?
var = None
if isinstance(lvalue.base, RefExpr) and isinstance(lvalue.base.node, Var):
var = lvalue.... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,818 | 3,855 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,882 | type_requires_usage | def type_requires_usage(self, typ: Type) -> tuple[str, ErrorCode] | None:
"""Some types require usage in all cases. The classic example is
an unused coroutine.
In the case that it does require usage, returns a note to attach
to the error message.
"""
proper_type = get_pr... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,857 | 3,872 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,883 | visit_expression_stmt | def visit_expression_stmt(self, s: ExpressionStmt) -> None:
expr_type = self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
error_note_and_code = self.type_requires_usage(expr_type)
if error_note_and_code:
error_note, code = error_note_and_code
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,874 | 3,882 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,884 | visit_return_stmt | def visit_return_stmt(self, s: ReturnStmt) -> None:
"""Type check a return statement."""
self.check_return_stmt(s)
self.binder.unreachable() | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,884 | 3,887 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,885 | check_return_stmt | def check_return_stmt(self, s: ReturnStmt) -> None:
defn = self.scope.top_function()
if defn is not None:
if defn.is_generator:
return_type = self.get_generator_return_type(
self.return_types[-1], defn.is_coroutine
)
elif defn.i... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,889 | 3,981 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,886 | visit_if_stmt | def visit_if_stmt(self, s: IfStmt) -> None:
"""Type check an if statement."""
# This frame records the knowledge from previous if/elif clauses not being taken.
# Fall-through to the original frame is handled explicitly in each block.
with self.binder.frame_context(can_skip=False, conditi... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 3,983 | 4,006 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,887 | visit_while_stmt | def visit_while_stmt(self, s: WhileStmt) -> None:
"""Type check a while statement."""
if_stmt = IfStmt([s.expr], [s.body], None)
if_stmt.set_line(s)
self.accept_loop(if_stmt, s.else_body, exit_condition=s.expr) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,008 | 4,012 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,888 | visit_operator_assignment_stmt | def visit_operator_assignment_stmt(self, s: OperatorAssignmentStmt) -> None:
"""Type check an operator assignment statement, e.g. x += 1."""
self.try_infer_partial_generic_type_from_assignment(s.lvalue, s.rvalue, s.op)
if isinstance(s.lvalue, MemberExpr):
# Special case, some additio... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,014 | 4,036 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,889 | visit_assert_stmt | def visit_assert_stmt(self, s: AssertStmt) -> None:
self.expr_checker.accept(s.expr)
if isinstance(s.expr, TupleExpr) and len(s.expr.items) > 0:
self.fail(message_registry.MALFORMED_ASSERT, s)
# If this is asserting some isinstance check, bind that type in the following code
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,038 | 4,048 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,890 | visit_raise_stmt | def visit_raise_stmt(self, s: RaiseStmt) -> None:
"""Type check a raise statement."""
if s.expr:
self.type_check_raise(s.expr, s)
if s.from_expr:
self.type_check_raise(s.from_expr, s, optional=True)
self.binder.unreachable() | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,050 | 4,056 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,891 | type_check_raise | def type_check_raise(self, e: Expression, s: RaiseStmt, optional: bool = False) -> None:
typ = get_proper_type(self.expr_checker.accept(e))
if isinstance(typ, DeletedType):
self.msg.deleted_as_rvalue(typ, e)
return
exc_type = self.named_type("builtins.BaseException")
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,058 | 4,077 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,892 | visit_try_stmt | def visit_try_stmt(self, s: TryStmt) -> None:
"""Type check a try statement."""
# Our enclosing frame will get the result if the try/except falls through.
# This one gets all possible states after the try block exited abnormally
# (by exception, return, break, etc.)
with self.bin... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,079 | 4,110 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,893 | visit_try_without_finally | def visit_try_without_finally(self, s: TryStmt, try_frame: bool) -> None:
"""Type check a try statement, ignoring the finally block.
On entry, the top frame should receive all flow that exits the
try block abnormally (i.e., such that the else block does not
execute), and its parent shou... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,112 | 4,158 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,894 | check_except_handler_test | def check_except_handler_test(self, n: Expression) -> Type:
"""Type check an exception handler test clause."""
typ = self.expr_checker.accept(n)
all_types: list[Type] = []
test_types = self.get_types_from_except_handler(typ, n)
for ttype in get_proper_types(test_types):
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,160 | 4,190 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,895 | get_types_from_except_handler | def get_types_from_except_handler(self, typ: Type, n: Expression) -> list[Type]:
"""Helper for check_except_handler_test to retrieve handler types."""
typ = get_proper_type(typ)
if isinstance(typ, TupleType):
return typ.items
elif isinstance(typ, UnionType):
retur... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,192 | 4,207 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,896 | visit_for_stmt | def visit_for_stmt(self, s: ForStmt) -> None:
"""Type check a for statement."""
if s.is_async:
iterator_type, item_type = self.analyze_async_iterable_item_type(s.expr)
else:
iterator_type, item_type = self.analyze_iterable_item_type(s.expr)
s.inferred_item_type = ... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,209 | 4,218 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,897 | analyze_async_iterable_item_type | def analyze_async_iterable_item_type(self, expr: Expression) -> tuple[Type, Type]:
"""Analyse async iterable expression and return iterator and iterator item types."""
echk = self.expr_checker
iterable = echk.accept(expr)
iterator = echk.check_method_call_by_name("__aiter__", iterable, [... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,220 | 4,229 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,898 | analyze_iterable_item_type | def analyze_iterable_item_type(self, expr: Expression) -> tuple[Type, Type]:
"""Analyse iterable expression and return iterator and iterator item types."""
echk = self.expr_checker
iterable = get_proper_type(echk.accept(expr))
iterator = echk.check_method_call_by_name("__iter__", iterabl... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,231 | 4,244 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,899 | analyze_container_item_type | def analyze_container_item_type(self, typ: Type) -> Type | None:
"""Check if a type is a nominal container of a union of such.
Return the corresponding container item type.
"""
typ = get_proper_type(typ)
if isinstance(typ, UnionType):
types: list[Type] = []
... | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,246 | 4,266 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
6,067,900 | analyze_index_variables | def analyze_index_variables(
self, index: Expression, item_type: Type, infer_lvalue_type: bool, context: Context
) -> None:
"""Type check or infer for loop or list comprehension index vars."""
self.check_assignment(index, self.temp_node(item_type, context), infer_lvalue_type) | python | python-3.10.8.amd64/Lib/site-packages/mypy/checker.py | 4,268 | 4,272 | {
"name": "PortablePy/3.10.8.0",
"url": "https://github.com/PortablePy/3.10.8.0.git",
"license": "NOASSERTION",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.