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,068,401
visit_callable_type
def visit_callable_type(self, left: CallableType) -> bool: right = self.right if isinstance(right, CallableType): if left.type_guard is not None and right.type_guard is not None: if not self._is_subtype(left.type_guard, right.type_guard): return False ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
643
683
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,402
visit_tuple_type
def visit_tuple_type(self, left: TupleType) -> bool: right = self.right if isinstance(right, Instance): if is_named_instance(right, "typing.Sized"): return True elif is_named_instance(right, TUPLE_LIKE_INSTANCE_NAMES): if right.args: ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
685
725
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,403
visit_typeddict_type
def visit_typeddict_type(self, left: TypedDictType) -> bool: right = self.right if isinstance(right, Instance): return self._is_subtype(left.fallback, right) elif isinstance(right, TypedDictType): if not left.names_are_wider_than(right): return False ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
727
761
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,404
visit_literal_type
def visit_literal_type(self, left: LiteralType) -> bool: if isinstance(self.right, LiteralType): return left == self.right else: return self._is_subtype(left.fallback, self.right)
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
763
767
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,405
visit_overloaded
def visit_overloaded(self, left: Overloaded) -> bool: right = self.right if isinstance(right, Instance): if right.type.is_protocol and right.type.protocol_members == ["__call__"]: # same as for CallableType call = find_member("__call__", right, left, is_operat...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
769
849
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,406
visit_union_type
def visit_union_type(self, left: UnionType) -> bool: if isinstance(self.right, Instance): literal_types: set[Instance] = set() # avoid redundant check for union of literals for item in left.relevant_items(): p_item = get_proper_type(item) lit_t...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
851
866
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,407
visit_partial_type
def visit_partial_type(self, left: PartialType) -> bool: # This is indeterminate as we don't really know the complete type yet. if self.proper_subtype: # TODO: What's the right thing to do here? return False if left.type is None: # Special case, partial `None`...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
868
879
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,408
visit_type_type
def visit_type_type(self, left: TypeType) -> bool: right = self.right if isinstance(right, TypeType): return self._is_subtype(left.item, right.item) if isinstance(right, CallableType): if self.proper_subtype and not right.is_type_obj(): # We can't accept `...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
881
905
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,409
visit_type_alias_type
def visit_type_alias_type(self, left: TypeAliasType) -> bool: assert False, f"This should be never called, got {left}"
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
907
908
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,410
pop_on_exit
def pop_on_exit(stack: list[tuple[T, T]], left: T, right: T) -> Iterator[None]: stack.append((left, right)) yield stack.pop()
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
915
918
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,411
is_protocol_implementation
def is_protocol_implementation( left: Instance, right: Instance, proper_subtype: bool = False ) -> bool: """Check whether 'left' implements the protocol 'right'. If 'proper_subtype' is True, then check for a proper subtype. Treat recursive protocols by using the 'assuming' structural subtype matrix ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
921
1,016
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,412
find_member
def find_member( name: str, itype: Instance, subtype: Type, is_operator: bool = False ) -> Type | None: """Find the type of member by 'name' in 'itype's TypeInfo. Find the member type after applying type arguments from 'itype', and binding 'self' to 'subtype'. Return None if member was not found. "...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,019
1,067
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,413
get_member_flags
def get_member_flags(name: str, info: TypeInfo) -> set[int]: """Detect whether a member 'name' is settable, whether it is an instance or class variable, and whether it is class or static method. The flags are defined as following: * IS_SETTABLE: whether this attribute can be set, not set for methods an...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,070
1,106
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,414
find_node_type
def find_node_type(node: Var | FuncBase, itype: Instance, subtype: Type) -> Type: """Find type of a variable or method 'node' (maybe also a decorated method). Apply type arguments from 'itype', and bind 'self' to 'subtype'. """ from mypy.typeops import bind_self if isinstance(node, FuncBase): ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,109
1,141
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,415
non_method_protocol_members
def non_method_protocol_members(tp: TypeInfo) -> list[str]: """Find all non-callable members of a protocol.""" assert tp.is_protocol result: list[str] = [] anytype = AnyType(TypeOfAny.special_form) instance = Instance(tp, [anytype] * len(tp.defn.type_vars)) for member in tp.protocol_members: ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,144
1,156
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,416
is_callable_compatible
def is_callable_compatible( left: CallableType, right: CallableType, *, is_compat: Callable[[Type, Type], bool], is_compat_return: Callable[[Type, Type], bool] | None = None, ignore_return: bool = False, ignore_pos_arg_names: bool = False, check_args_covariantly: bool = False, allow_...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,159
1,323
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,417
are_parameters_compatible
def are_parameters_compatible( left: Parameters | NormalizedCallableType, right: Parameters | NormalizedCallableType, *, is_compat: Callable[[Type, Type], bool], ignore_pos_arg_names: bool = False, check_args_covariantly: bool = False, allow_partial_overlap: bool = False, strict_concaten...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,326
1,491
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,418
_incompatible
def _incompatible(left_arg: FormalArgument | None, right_arg: FormalArgument | None) -> bool: if right_arg is None: return False if left_arg is None: return not allow_partial_overlap return not is_compat(right_arg.typ, left_arg.typ)
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,380
1,385
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,419
are_args_compatible
def are_args_compatible( left: FormalArgument, right: FormalArgument, ignore_pos_arg_names: bool, allow_partial_overlap: bool, is_compat: Callable[[Type, Type], bool], ) -> bool: def is_different(left_item: object | None, right_item: object | None) -> bool: """Checks if the left and righ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,494
1,538
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,420
is_different
def is_different(left_item: object | None, right_item: object | None) -> bool: """Checks if the left and right items are different. If the right item is unspecified (e.g. if the right callable doesn't care about what name or position its arg has), we default to returning False. If we'r...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,501
1,513
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,421
flip_compat_check
def flip_compat_check(is_compat: Callable[[Type, Type], bool]) -> Callable[[Type, Type], bool]: def new_is_compat(left: Type, right: Type) -> bool: return is_compat(right, left) return new_is_compat
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,541
1,545
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,422
new_is_compat
def new_is_compat(left: Type, right: Type) -> bool: return is_compat(right, left)
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,542
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,068,423
unify_generic_callable
def unify_generic_callable( type: NormalizedCallableType, target: NormalizedCallableType, ignore_return: bool, return_constraint_direction: int | None = None, ) -> NormalizedCallableType | None: """Try to unify a generic callable type with another callable type. Return unified CallableType if s...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,548
1,590
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,424
report
def report(*args: Any) -> None: nonlocal had_errors had_errors = True
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,581
1,583
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,425
try_restrict_literal_union
def try_restrict_literal_union(t: UnionType, s: Type) -> list[Type] | None: """Return the items of t, excluding any occurrence of s, if and only if - t only contains simple literals - s is a simple literal Otherwise, returns None """ ps = get_proper_type(s) if not mypy.typeops.is_simple...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,593
1,611
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,426
restrict_subtype_away
def restrict_subtype_away(t: Type, s: Type, *, ignore_promotions: bool = False) -> Type: """Return t minus s for runtime type assertions. If we can't determine a precise result, return a supertype of the ideal result (just t is a valid result). This is used for type inference of runtime type checks su...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,614
1,639
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,427
covers_at_runtime
def covers_at_runtime(item: Type, supertype: Type, ignore_promotions: bool) -> bool: """Will isinstance(item, supertype) always return True at runtime?""" item = get_proper_type(item) supertype = get_proper_type(supertype) # Since runtime type checks will ignore type arguments, erase the types. sup...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,642
1,662
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,428
is_more_precise
def is_more_precise(left: Type, right: Type, *, ignore_promotions: bool = False) -> bool: """Check if left is a more precise type than right. A left is a proper subtype of right, left is also more precise than right. Also, if right is Any, left is more precise than right, for any left. """ # TO...
python
python-3.10.8.amd64/Lib/site-packages/mypy/subtypes.py
1,665
1,676
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,429
find_unpack_in_list
def find_unpack_in_list(items: Sequence[Type]) -> int | None: unpack_index: int | None = None for i, item in enumerate(items): proper_item = get_proper_type(item) if isinstance(proper_item, UnpackType): # We cannot fail here, so we must check this in an earlier # semanal ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/typevartuples.py
10
22
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,430
split_with_prefix_and_suffix
def split_with_prefix_and_suffix( types: tuple[T, ...], prefix: int, suffix: int ) -> tuple[tuple[T, ...], tuple[T, ...], tuple[T, ...]]: if suffix: return (types[:prefix], types[prefix:-suffix], types[-suffix:]) else: return (types[:prefix], types[prefix:], ())
python
python-3.10.8.amd64/Lib/site-packages/mypy/typevartuples.py
28
34
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,431
split_with_instance
def split_with_instance( typ: Instance, ) -> tuple[tuple[Type, ...], tuple[Type, ...], tuple[Type, ...]]: assert typ.type.type_var_tuple_prefix is not None assert typ.type.type_var_tuple_suffix is not None return split_with_prefix_and_suffix( typ.args, typ.type.type_var_tuple_prefix, typ.type.ty...
python
python-3.10.8.amd64/Lib/site-packages/mypy/typevartuples.py
37
44
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,432
extract_unpack
def extract_unpack(types: Sequence[Type]) -> ProperType | None: """Given a list of types, extracts either a single type from an unpack, or returns None.""" if len(types) == 1: proper_type = get_proper_type(types[0]) if isinstance(proper_type, UnpackType): return get_proper_type(prope...
python
python-3.10.8.amd64/Lib/site-packages/mypy/typevartuples.py
47
53
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,433
special_function_elide_names
def special_function_elide_names(name: str) -> bool: return name in MAGIC_METHODS_POS_ARGS_ONLY
python
python-3.10.8.amd64/Lib/site-packages/mypy/sharedparse.py
107
108
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,434
argument_elide_name
def argument_elide_name(name: str | None) -> bool: return name is not None and name.startswith("__") and not name.endswith("__")
python
python-3.10.8.amd64/Lib/site-packages/mypy/sharedparse.py
111
112
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,435
map_actuals_to_formals
def map_actuals_to_formals( actual_kinds: list[nodes.ArgKind], actual_names: Sequence[str | None] | None, formal_kinds: list[nodes.ArgKind], formal_names: Sequence[str | None], actual_arg_type: Callable[[int], Type], ) -> list[list[int]]: """Calculate mapping between actual (caller) args and for...
python
python-3.10.8.amd64/Lib/site-packages/mypy/argmap.py
24
119
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,436
map_formals_to_actuals
def map_formals_to_actuals( actual_kinds: list[nodes.ArgKind], actual_names: Sequence[str | None] | None, formal_kinds: list[nodes.ArgKind], formal_names: list[str | None], actual_arg_type: Callable[[int], Type], ) -> list[list[int]]: """Calculate the reverse mapping of map_actuals_to_formals.""...
python
python-3.10.8.amd64/Lib/site-packages/mypy/argmap.py
122
138
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,437
__init__
def __init__(self, context: ArgumentInferContext) -> None: # Next tuple *args index to use. self.tuple_index = 0 # Keyword arguments in TypedDict **kwargs used. self.kwargs_used: set[str] = set() # Type context for `*` and `**` arg kinds. self.context = context
python
python-3.10.8.amd64/Lib/site-packages/mypy/argmap.py
163
169
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,438
expand_actual_type
def expand_actual_type( self, actual_type: Type, actual_kind: nodes.ArgKind, formal_name: str | None, formal_kind: nodes.ArgKind, ) -> Type: """Return the actual (caller) type(s) of a formal argument with the given kinds. If the actual argument is a tuple *ar...
python
python-3.10.8.amd64/Lib/site-packages/mypy/argmap.py
171
247
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,439
create_source_list
def create_source_list( paths: Sequence[str], options: Options, fscache: FileSystemCache | None = None, allow_empty_dir: bool = False, ) -> list[BuildSource]: """From a list of source files/directories, makes a list of BuildSources. Raises InvalidSourceList on errors. """ fscache = fsca...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
21
49
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,440
keyfunc
def keyfunc(name: str) -> tuple[bool, int, str]: """Determines sort order for directory listing. The desirable properties are: 1) foo < foo.pyi < foo.py 2) __init__.py[i] < foo """ base, suffix = os.path.splitext(name) for i, ext in enumerate(PY_EXTENSIONS): if suffix == ext: ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
52
63
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,441
normalise_package_base
def normalise_package_base(root: str) -> str: if not root: root = os.curdir root = os.path.abspath(root) if root.endswith(os.sep): root = root[:-1] return root
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
66
72
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,442
get_explicit_package_bases
def get_explicit_package_bases(options: Options) -> list[str] | None: """Returns explicit package bases to use if the option is enabled, or None if disabled. We currently use MYPYPATH and the current directory as the package bases. In the future, when --namespace-packages is the default could also use the ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
75
88
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,443
__init__
def __init__(self, fscache: FileSystemCache, options: Options) -> None: self.fscache = fscache self.explicit_package_bases = get_explicit_package_bases(options) self.namespace_packages = options.namespace_packages self.exclude = options.exclude self.verbosity = options.verbosity
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
92
97
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,444
is_explicit_package_base
def is_explicit_package_base(self, path: str) -> bool: assert self.explicit_package_bases return normalise_package_base(path) in self.explicit_package_bases
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
99
101
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,445
find_sources_in_dir
def find_sources_in_dir(self, path: str) -> list[BuildSource]: sources = [] seen: set[str] = set() names = sorted(self.fscache.listdir(path), key=keyfunc) for name in names: # Skip certain names altogether if name in ("__pycache__", "site-packages", "node_modules...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
103
129
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,446
crawl_up
def crawl_up(self, path: str) -> tuple[str, str]: """Given a .py[i] filename, return module and base directory. For example, given "xxx/yyy/foo/bar.py", we might return something like: ("foo.bar", "xxx/yyy") If namespace packages is off, we crawl upwards until we find a directory witho...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
131
158
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,447
crawl_up_dir
def crawl_up_dir(self, dir: str) -> tuple[str, str]: return self._crawl_up_helper(dir) or ("", dir)
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
160
161
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,448
_crawl_up_helper
def _crawl_up_helper(self, dir: str) -> tuple[str, str] | None: """Given a directory, maybe returns module and base directory. We return a non-None value if we were able to find something clearly intended as a base directory (as adjudicated by being an explicit base directory or by containing a...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
164
211
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,449
get_init_file
def get_init_file(self, dir: str) -> str | None: """Check whether a directory contains a file named __init__.py[i]. If so, return the file's name (with dir prefixed). If not, return None. This prefers .pyi over .py (because of the ordering of PY_EXTENSIONS). """ for ext in PY_...
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
213
226
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,450
module_join
def module_join(parent: str, child: str) -> str: """Join module ids, accounting for a possibly empty parent.""" if parent: return parent + "." + child return child
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
229
233
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,451
strip_py
def strip_py(arg: str) -> str | None: """Strip a trailing .py or .pyi suffix. Return None if no such suffix is found. """ for ext in PY_EXTENSIONS: if arg.endswith(ext): return arg[: -len(ext)] return None
python
python-3.10.8.amd64/Lib/site-packages/mypy/find_sources.py
236
244
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,452
__repr__
def __repr__(self) -> str: return "MISSING"
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
44
45
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,453
_style
def _style(message: str, **kwargs: Any) -> str: """Wrapper around mypy.util for fancy formatting.""" kwargs.setdefault("color", "none") return _formatter.style(message, **kwargs)
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
56
59
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,454
_truncate
def _truncate(message: str, length: int) -> str: if len(message) > length: return message[: length - 3] + "..." return message
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
62
65
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,455
__init__
def __init__( self, object_path: list[str], message: str, stub_object: MaybeMissing[nodes.Node], runtime_object: MaybeMissing[Any], *, stub_desc: str | None = None, runtime_desc: str | None = None, ) -> None: """Represents an error found by stu...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
73
100
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,456
is_missing_stub
def is_missing_stub(self) -> bool: """Whether or not the error is for something missing from the stub.""" return isinstance(self.stub_object, Missing)
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
102
104
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,457
is_positional_only_related
def is_positional_only_related(self) -> bool: """Whether or not the error is for something being (or not being) positional-only.""" # TODO: This is hacky, use error codes or something more resilient return "leading double underscore" in self.message
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
106
109
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,458
get_description
def get_description(self, concise: bool = False) -> str: """Returns a description of the error. :param concise: Whether to return a concise, one-line description """ if concise: return _style(self.object_desc, bold=True) + " " + self.message stub_line = None ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
111
167
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,459
silent_import_module
def silent_import_module(module_name: str) -> types.ModuleType: with open(os.devnull, "w") as devnull: with warnings.catch_warnings(), redirect_stdout(devnull), redirect_stderr(devnull): warnings.simplefilter("ignore") runtime = importlib.import_module(module_name) # Also...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
175
184
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,460
test_module
def test_module(module_name: str) -> Iterator[Error]: """Tests a given module's stub against introspecting it at runtime. Requires the stub to have been built already, accomplished by a call to ``build_stubs``. :param module_name: The module to test """ stub = get_stub(module_name) if stub is...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
187
233
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,461
verify
def verify( stub: MaybeMissing[nodes.Node], runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: """Entry point for comparing a stub to a runtime object. We use single dispatch based on the type of ``stub``. :param stub: The mypy node representing a part of the stub :param runt...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
237
248
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,462
_verify_exported_names
def _verify_exported_names( object_path: list[str], stub: nodes.MypyFile, runtime_all_as_set: set[str] ) -> Iterator[Error]: # note that this includes the case the stub simply defines `__all__: list[str]` assert "__all__" in stub.names public_names_in_stub = {m for m, o in stub.names.items() if o.module...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
251
279
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,463
verify_mypyfile
def verify_mypyfile( stub: nodes.MypyFile, runtime: MaybeMissing[types.ModuleType], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): yield Error(object_path, "is not present at runtime", stub, runtime) return if not isinstance(runtime, types.ModuleType): ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
283
349
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,464
_belongs_to_runtime
def _belongs_to_runtime(r: types.ModuleType, attr: str) -> bool: obj = getattr(r, attr) try: obj_mod = getattr(obj, "__module__", None) except Exception: return False if obj_mod is not None: return obj_mod == r.__name__ return not isinstance(ob...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
311
319
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,465
verify_typeinfo
def verify_typeinfo( stub: nodes.TypeInfo, runtime: MaybeMissing[type[Any]], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): yield Error(object_path, "is not present at runtime", stub, runtime, stub_desc=repr(stub)) return if not isinstance(runtime, type): ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
353
425
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,466
_verify_static_class_methods
def _verify_static_class_methods( stub: nodes.FuncBase, runtime: Any, object_path: list[str] ) -> Iterator[str]: if stub.name in ("__new__", "__init_subclass__", "__class_getitem__"): # Special cased by Python, so don't bother checking return if inspect.isbuiltin(runtime): # The isin...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
428
462
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,467
_verify_arg_name
def _verify_arg_name( stub_arg: nodes.Argument, runtime_arg: inspect.Parameter, function_name: str ) -> Iterator[str]: """Checks whether argument names match.""" # Ignore exact names for most dunder methods if is_dunder(function_name, exclude_special=True): return def strip_prefix(s: str, p...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
465
495
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,468
strip_prefix
def strip_prefix(s: str, prefix: str) -> str: return s[len(prefix) :] if s.startswith(prefix) else s
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
473
474
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,469
names_approx_match
def names_approx_match(a: str, b: str) -> bool: a = a.strip("_") b = b.strip("_") return a.startswith(b) or b.startswith(a) or len(a) == 1 or len(b) == 1
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
479
482
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,470
_verify_arg_default_value
def _verify_arg_default_value( stub_arg: nodes.Argument, runtime_arg: inspect.Parameter ) -> Iterator[str]: """Checks whether argument default values are compatible.""" if runtime_arg.default != inspect.Parameter.empty: if stub_arg.kind.is_required(): yield ( f'runtime ar...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
498
536
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,471
maybe_strip_cls
def maybe_strip_cls(name: str, args: list[nodes.Argument]) -> list[nodes.Argument]: if name in ("__init_subclass__", "__class_getitem__"): # These are implicitly classmethods. If the stub chooses not to have @classmethod, we # should remove the cls argument if args[0].variable.name == "cls":...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
539
545
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,472
__init__
def __init__(self) -> None: self.pos: list[T] = [] self.kwonly: dict[str, T] = {} self.varpos: T | None = None self.varkw: T | None = None
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
549
553
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,473
__str__
def __str__(self) -> str: def get_name(arg: Any) -> str: if isinstance(arg, inspect.Parameter): return arg.name if isinstance(arg, nodes.Argument): return arg.variable.name raise AssertionError def get_type(arg: Any) -> str | None: ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
555
594
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,474
get_name
def get_name(arg: Any) -> str: if isinstance(arg, inspect.Parameter): return arg.name if isinstance(arg, nodes.Argument): return arg.variable.name raise AssertionError
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
556
561
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,475
get_type
def get_type(arg: Any) -> str | None: if isinstance(arg, inspect.Parameter): return None if isinstance(arg, nodes.Argument): return str(arg.variable.type or arg.type_annotation) raise AssertionError
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
563
568
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,476
has_default
def has_default(arg: Any) -> bool: if isinstance(arg, inspect.Parameter): return arg.default != inspect.Parameter.empty if isinstance(arg, nodes.Argument): return arg.kind.is_optional() raise AssertionError
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
570
575
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,477
get_desc
def get_desc(arg: Any) -> str: arg_type = get_type(arg) return ( get_name(arg) + (f": {arg_type}" if arg_type else "") + (" = ..." if has_default(arg) else "") )
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
577
583
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,478
from_funcitem
def from_funcitem(stub: nodes.FuncItem) -> Signature[nodes.Argument]: stub_sig: Signature[nodes.Argument] = Signature() stub_args = maybe_strip_cls(stub.name, stub.arguments) for stub_arg in stub_args: if stub_arg.kind.is_positional(): stub_sig.pos.append(stub_arg) ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
597
611
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,479
from_inspect_signature
def from_inspect_signature(signature: inspect.Signature) -> Signature[inspect.Parameter]: runtime_sig: Signature[inspect.Parameter] = Signature() for runtime_arg in signature.parameters.values(): if runtime_arg.kind in ( inspect.Parameter.POSITIONAL_ONLY, insp...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
614
630
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,480
from_overloadedfuncdef
def from_overloadedfuncdef(stub: nodes.OverloadedFuncDef) -> Signature[nodes.Argument]: """Returns a Signature from an OverloadedFuncDef. If life were simple, to verify_overloadedfuncdef, we'd just verify_funcitem for each of its items. Unfortunately, life isn't simple and overloads are pretty ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
633
709
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,481
get_position
def get_position(arg_name: str) -> int: # We just need this to return the positional args in the correct order. return max(index for _, index in all_args[arg_name])
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
659
661
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,482
get_type
def get_type(arg_name: str) -> mypy.types.ProperType: with mypy.state.state.strict_optional_set(True): all_types = [ arg.variable.type or arg.type_annotation for arg, _ in all_args[arg_name] ] return mypy.typeops.make_simplified_union([t fo...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
663
668
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,483
get_kind
def get_kind(arg_name: str) -> nodes.ArgKind: kinds = {arg.kind for arg, _ in all_args[arg_name]} if nodes.ARG_STAR in kinds: return nodes.ARG_STAR if nodes.ARG_STAR2 in kinds: return nodes.ARG_STAR2 # The logic here is based on two tenets:...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
670
687
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,484
_verify_signature
def _verify_signature( stub: Signature[nodes.Argument], runtime: Signature[inspect.Parameter], function_name: str ) -> Iterator[str]: # Check positional arguments match up for stub_arg, runtime_arg in zip(stub.pos, runtime.pos): yield from _verify_arg_name(stub_arg, runtime_arg, function_name) ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
712
811
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,485
verify_funcitem
def verify_funcitem( stub: nodes.FuncItem, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): yield Error(object_path, "is not present at runtime", stub, runtime) return if not is_probably_a_function(runtime): yield Error(object...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
815
876
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,486
verify_none
def verify_none( stub: Missing, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: yield Error(object_path, "is not present in stub", stub, runtime)
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
880
883
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,487
verify_var
def verify_var( stub: nodes.Var, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): # Don't always yield an error here, because we often can't find instance variables if len(object_path) <= 2: yield Error(object_path, "is not pre...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
887
920
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,488
verify_overloadedfuncdef
def verify_overloadedfuncdef( stub: nodes.OverloadedFuncDef, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): yield Error(object_path, "is not present at runtime", stub, runtime) return if stub.is_property: # Any property with...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
924
966
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,489
verify_typevarexpr
def verify_typevarexpr( stub: nodes.TypeVarExpr, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): # We seem to insert these typevars into NamedTuple stubs, but they # don't exist at runtime. Just ignore! if stub.name == "_NT": ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
970
982
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,490
verify_paramspecexpr
def verify_paramspecexpr( stub: nodes.ParamSpecExpr, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): yield Error(object_path, "is not present at runtime", stub, runtime) return maybe_paramspec_types = ( getattr(typing, "ParamS...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
986
999
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,491
_verify_readonly_property
def _verify_readonly_property(stub: nodes.Decorator, runtime: Any) -> Iterator[str]: assert stub.func.is_property if isinstance(runtime, property): return if inspect.isdatadescriptor(runtime): # It's enough like a property... return # Sometimes attributes pretend to be properties...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,002
1,021
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,492
_resolve_funcitem_from_decorator
def _resolve_funcitem_from_decorator(dec: nodes.OverloadPart) -> nodes.FuncItem | None: """Returns a FuncItem that corresponds to the output of the decorator. Returns None if we can't figure out what that would be. For convenience, this function also accepts FuncItems. """ if isinstance(dec, nodes....
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,024
1,069
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,493
apply_decorator_to_funcitem
def apply_decorator_to_funcitem( decorator: nodes.Expression, func: nodes.FuncItem ) -> nodes.FuncItem | None: if not isinstance(decorator, nodes.RefExpr): return None if decorator.fullname is None: # Happens with namedtuple return None if ( ...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,035
1,061
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,494
verify_decorator
def verify_decorator( stub: nodes.Decorator, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: if isinstance(runtime, Missing): yield Error(object_path, "is not present at runtime", stub, runtime) return if stub.func.is_property: for message in _verify_readonly...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,073
1,086
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,495
verify_typealias
def verify_typealias( stub: nodes.TypeAlias, runtime: MaybeMissing[Any], object_path: list[str] ) -> Iterator[Error]: stub_target = mypy.types.get_proper_type(stub.target) stub_desc = f"Type alias for {stub_target}" if isinstance(runtime, Missing): yield Error(object_path, "is not present at run...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,090
1,158
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,496
is_probably_private
def is_probably_private(name: str) -> bool: return name.startswith("_") and not is_dunder(name)
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,238
1,239
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,497
is_probably_a_function
def is_probably_a_function(runtime: Any) -> bool: return ( isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType)) or isinstance(runtime, (types.MethodType, types.BuiltinMethodType)) or (inspect.ismethoddescriptor(runtime) and callable(runtime)) )
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,242
1,247
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,498
is_read_only_property
def is_read_only_property(runtime: object) -> bool: return isinstance(runtime, property) and runtime.fset is None
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,250
1,251
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,499
safe_inspect_signature
def safe_inspect_signature(runtime: Any) -> inspect.Signature | None: try: return inspect.signature(runtime) except Exception: # inspect.signature throws ValueError all the time # catch RuntimeError because of https://bugs.python.org/issue39504 # catch TypeError because of https:...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,254
1,262
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }
6,068,500
is_subtype_helper
def is_subtype_helper(left: mypy.types.Type, right: mypy.types.Type) -> bool: """Checks whether ``left`` is a subtype of ``right``.""" left = mypy.types.get_proper_type(left) right = mypy.types.get_proper_type(right) if ( isinstance(left, mypy.types.LiteralType) and isinstance(left.value...
python
python-3.10.8.amd64/Lib/site-packages/mypy/stubtest.py
1,265
1,288
{ "name": "PortablePy/3.10.8.0", "url": "https://github.com/PortablePy/3.10.8.0.git", "license": "NOASSERTION", "stars": 0, "forks": 0 }