diff --git a/extensions/mypy_extensions.py b/extensions/mypy_extensions.py index c711e0023a0f..056b1bf7c63e 100644 --- a/extensions/mypy_extensions.py +++ b/extensions/mypy_extensions.py @@ -46,7 +46,7 @@ def __new__(cls, name, bases, ns, total=True): # This method is called directly when TypedDict is subclassed, # or via _typeddict_new when TypedDict is instantiated. This way # TypedDict supports all three syntaxes described in its docstring. - # Subclasses and instanes of TypedDict return actual dictionaries + # Subclasses and instances of TypedDict return actual dictionaries # via _dict_new. ns['__new__'] = _typeddict_new if name == 'TypedDict' else _dict_new tp_dict = super(_TypedDictMeta, cls).__new__(cls, name, (dict,), ns) diff --git a/mypy/binder.py b/mypy/binder.py index 0cba54fd03ec..15c728d54b11 100644 --- a/mypy/binder.py +++ b/mypy/binder.py @@ -354,7 +354,7 @@ def frame_context(self, *, can_skip: bool, fall_through: int = 1, continue_frame and 'continue' statements. If try_frame is true, then execution is allowed to jump at any - point within the newly created frame (or its descendents) to + point within the newly created frame (or its descendants) to its parent (i.e., to the frame that was on top before this call to frame_context). diff --git a/mypy/checker.py b/mypy/checker.py index fe8fc2d32374..4b57be30d251 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -2177,12 +2177,12 @@ def check_simple_assignment(self, lvalue_type: Optional[Type], rvalue: Expressio def check_member_assignment(self, instance_type: Type, attribute_type: Type, rvalue: Expression, context: Context) -> Tuple[Type, bool]: - """Type member assigment. + """Type member assignment. This defers to check_simple_assignment, unless the member expression is a descriptor, in which case this checks descriptor semantics as well. - Return the inferred rvalue_type and whether to infer anything about the attribute type + Return the inferred rvalue_type and whether to infer anything about the attribute type. """ # Descriptors don't participate in class-attribute access if ((isinstance(instance_type, FunctionLike) and instance_type.is_type_obj()) or @@ -3246,7 +3246,7 @@ def enter_partial_types(self, *, is_function: bool = False, if not self.current_node_deferred: for var, context in partial_types.items(): # If we require local partial types, there are a few exceptions where - # we fall back to inferring just "None" as the type from a None initaliazer: + # we fall back to inferring just "None" as the type from a None initializer: # # 1. If all happens within a single function this is acceptable, since only # the topmost function is a separate target in fine-grained incremental mode. diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 69c72198e32d..cabe3ecf41c5 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -156,7 +156,7 @@ def analyze_ref_expr(self, e: RefExpr, lvalue: bool = False) -> Type: result = function_type(node, self.named_type('builtins.function')) elif isinstance(node, OverloadedFuncDef) and node.type is not None: # node.type is None when there are multiple definitions of a function - # and it's decorated by somthing that is not typing.overload + # and it's decorated by something that is not typing.overload result = node.type elif isinstance(node, TypeInfo): # Reference to a type object. @@ -536,7 +536,7 @@ def check_call(self, callee: Type, args: List[Expression], if specified arg_messages: TODO callable_name: Fully-qualified name of the function/method to call, - or None if unavaiable (examples: 'builtins.open', 'typing.Mapping.get') + or None if unavailable (examples: 'builtins.open', 'typing.Mapping.get') object_type: If callable_name refers to a method, the type of the object on which the method is being called """ @@ -2831,7 +2831,7 @@ def visit_enum_call_expr(self, e: EnumCallExpr) -> Type: if not isinstance(typ, AnyType): var = e.info.names[name].node if isinstance(var, Var): - # Inline TypeCheker.set_inferred_type(), + # Inline TypeChecker.set_inferred_type(), # without the lvalue. (This doesn't really do # much, since the value attribute is defined # to have type Any in the typeshed stub.) diff --git a/mypy/checkmember.py b/mypy/checkmember.py index 2c80ab0a325e..4633a8310446 100644 --- a/mypy/checkmember.py +++ b/mypy/checkmember.py @@ -299,7 +299,7 @@ def analyze_var(name: str, var: Var, itype: Instance, info: TypeInfo, node: Cont This is conceptually part of analyze_member_access and the arguments are similar. - itype is the class object in which var is dedined + itype is the class object in which var is defined original_type is the type of E in the expression E.var """ # Found a member variable. diff --git a/mypy/errors.py b/mypy/errors.py index f2d4da76baf8..24fd16dcbb19 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -506,7 +506,7 @@ def remove_duplicates(self, errors: List[Tuple[Optional[str], int, int, str, str while (j >= 0 and errors[j][0] == errors[i][0] and errors[j][1] == errors[i][1]): if (errors[j][3] == errors[i][3] and - # Allow duplicate notes in overload conficts reporting + # Allow duplicate notes in overload conflicts reporting. not (errors[i][3] == 'note' and errors[i][4].strip() in allowed_duplicates or errors[i][4].strip().startswith('def ')) and diff --git a/mypy/exprtotype.py b/mypy/exprtotype.py index 0e1fcef5f7bd..a997cedcd755 100644 --- a/mypy/exprtotype.py +++ b/mypy/exprtotype.py @@ -32,7 +32,7 @@ def expr_to_unanalyzed_type(expr: Expression, _parent: Optional[Expression] = No The result is not semantically analyzed. It can be UnboundType or TypeList. Raise TypeTranslationError if the expression cannot represent a type. """ - # The `parent` paremeter is used in recursive calls to provide context for + # The `parent` parameter is used in recursive calls to provide context for # understanding whether an CallableArgument is ok. name = None # type: Optional[str] if isinstance(expr, NameExpr): diff --git a/mypy/fastparse2.py b/mypy/fastparse2.py index 7d3cff2cc923..86286d49391f 100644 --- a/mypy/fastparse2.py +++ b/mypy/fastparse2.py @@ -11,7 +11,7 @@ The reason why this file is not easily merged with mypy.fastparse despite the large amount of redundancy is because the Python 2 AST and the Python 3 AST nodes belong to two completely -different class heirarchies, which made it difficult to write a shared visitor between the +different class hierarchies, which made it difficult to write a shared visitor between the two in a typesafe way. """ from functools import wraps diff --git a/mypy/nodes.py b/mypy/nodes.py index 61d86df0c537..5c9d021edda9 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -2223,7 +2223,7 @@ def protocol_members(self) -> List[str]: # Protocol members are names of all attributes/methods defined in a protocol # and in all its supertypes (except for 'object'). members = set() # type: Set[str] - assert self.mro, "This property can be only acessed after MRO is (re-)calculated" + assert self.mro, "This property can be only accessed after MRO is (re-)calculated" for base in self.mro[:-1]: # we skip "object" since everyone implements it if base.is_protocol: for name in base.names: @@ -2390,7 +2390,7 @@ def deserialize(cls, data: JsonDict) -> 'TypeInfo': # not be loaded until after a class in the mro has changed its # bases, which causes the mro to change. If we recomputed our # mro, we would compute the *new* mro, which leaves us with no - # way to detact that the mro has changed! Thus we need to make + # way to detect that the mro has changed! Thus we need to make # sure to load the original mro so that once the class is # rechecked, it can tell that the mro has changed. ti._mro_refs = data['mro'] diff --git a/mypy/plugins/attrs.py b/mypy/plugins/attrs.py index b5a577b4b016..028b86ca8550 100644 --- a/mypy/plugins/attrs.py +++ b/mypy/plugins/attrs.py @@ -56,7 +56,7 @@ def argument(self, ctx: 'mypy.plugin.ClassDefContext') -> Argument: init_type = self.info[self.name].type if self.converter_name: - # When a converter is set the init_type is overriden by the first argument + # When a converter is set the init_type is overridden by the first argument # of the converter method. converter = lookup_qualified_stnode(ctx.api.modules, self.converter_name, True) if not converter: diff --git a/mypy/semanal.py b/mypy/semanal.py index b241cb047acd..897f18d261fd 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -585,7 +585,7 @@ def _visit_overloaded_func_def(self, defn: OverloadedFuncDef) -> None: if not defn.items: # It was not any kind of overload def after all. We've visited the - # redfinitions already. + # redefinitions already. return if self.type and not self.is_func_scope(): @@ -862,7 +862,7 @@ def setup_type_promotion(self, defn: ClassDef) -> None: if isinstance(decorator, CallExpr): analyzed = decorator.analyzed if isinstance(analyzed, PromoteExpr): - # _promote class decorator (undocumented faeture). + # _promote class decorator (undocumented feature). promote_target = analyzed.type if not promote_target: promotions = (TYPE_PROMOTIONS_PYTHON3 if self.options.python_version[0] >= 3 diff --git a/mypy/semanal_pass1.py b/mypy/semanal_pass1.py index 7e2e91194009..31f3e204a5c3 100644 --- a/mypy/semanal_pass1.py +++ b/mypy/semanal_pass1.py @@ -13,7 +13,7 @@ definitions, as these look like regular assignments until we are able to bind names, which only happens in pass 2. -This pass also infers the reachability of certain if staments, such as +This pass also infers the reachability of certain if statements, such as those with platform checks. """ diff --git a/mypy/semanal_pass3.py b/mypy/semanal_pass3.py index 5a5596354387..e252f1a7d5c7 100644 --- a/mypy/semanal_pass3.py +++ b/mypy/semanal_pass3.py @@ -205,7 +205,7 @@ def visit_decorator(self, dec: Decorator) -> None: sig = find_fixed_callable_return(dec.decorators[0]) if sig: # The outermost decorator always returns the same kind of function, - # so we know that this is the type of the decoratored function. + # so we know that this is the type of the decorated function. orig_sig = function_type(dec.func, self.builtin_type('function')) sig.name = orig_sig.items()[0].name dec.var.type = sig diff --git a/mypy/server/astmerge.py b/mypy/server/astmerge.py index 7ab4fd728364..50a40c319336 100644 --- a/mypy/server/astmerge.py +++ b/mypy/server/astmerge.py @@ -4,7 +4,7 @@ we build a new AST from the updated source. However, other parts of the program may have direct references to parts of the old AST (namely, those nodes exposed in the module symbol table). The merge operation changes the identities of new -AST nodes that have a correspondance in the old AST to the old ones so that +AST nodes that have a correspondence in the old AST to the old ones so that existing cross-references in other modules will continue to point to the correct nodes. Also internal cross-references within the new AST are replaced. AST nodes that aren't externally visible will get new, distinct object identities. This @@ -15,7 +15,7 @@ translation when looking up references (which would be hard to retrofit). The AST merge operation is performed after semantic analysis. Semantic -analysis has to deal with potentionally multiple aliases to certain AST +analysis has to deal with potentially multiple aliases to certain AST nodes (in particular, MypyFile nodes). Type checking assumes that we don't have multiple variants of a single AST node visible to the type checker. @@ -28,7 +28,7 @@ * If a function is replaced with another function with an identical signature, call sites continue to point to the same object (by identity) and don't need - to be reprocessed. Similary, if a class is replaced with a class that is + to be reprocessed. Similarly, if a class is replaced with a class that is sufficiently similar (MRO preserved, etc.), class references don't need any processing. A typical incremental update to a file only changes a few externally visible things in a module, and this means that often only few diff --git a/mypy/server/deps.py b/mypy/server/deps.py index f3df6fdb7b0e..8687222e0d1f 100644 --- a/mypy/server/deps.py +++ b/mypy/server/deps.py @@ -11,7 +11,7 @@ function or method, or a module top level), a class, or a trigger (for recursively triggering other triggers). -Here's an example represention of a simple dependency map (in format +Here's an example representation of a simple dependency map (in format " -> locations"): -> m.f @@ -499,7 +499,7 @@ def process_global_ref_expr(self, o: RefExpr) -> None: # If this is a reference to a type, generate a dependency to its # constructor. - # TODO: avoid generating spurious dependencies for isinstancce checks, + # TODO: avoid generating spurious dependencies for isinstance checks, # except statements, class attribute reference, etc, if perf problem. typ = self.type_map.get(o) if isinstance(typ, FunctionLike) and typ.is_type_obj(): @@ -509,7 +509,7 @@ def process_global_ref_expr(self, o: RefExpr) -> None: def visit_name_expr(self, o: NameExpr) -> None: if o.kind == LDEF: - # We don't track depdendencies to local variables, since they + # We don't track dependencies to local variables, since they # aren't externally visible. return if o.kind == MDEF: diff --git a/mypy/server/update.py b/mypy/server/update.py index 0dbc0b02ba3d..a2084cac35a1 100644 --- a/mypy/server/update.py +++ b/mypy/server/update.py @@ -331,7 +331,7 @@ def update_module(self, # its tree loaded so that we can snapshot it for comparison. ensure_trees_loaded(manager, graph, [module]) - # Record symbol table snaphot of old version the changed module. + # Record symbol table snapshot of old version the changed module. old_snapshots = {} # type: Dict[str, Dict[str, SnapshotItem]] if module in manager.modules: snapshot = snapshot_symbol_table(module, manager.modules[module].names) @@ -446,7 +446,7 @@ def update_module_isolated(module: str, force_removed: bool) -> UpdateResult: """Build a new version of one changed module only. - Don't propagate changes to elsewhere in the program. Raise CompleError on + Don't propagate changes to elsewhere in the program. Raise CompileError on encountering a blocking error. Args: diff --git a/mypy/stubgen.py b/mypy/stubgen.py index 9e12576c1b19..180f0265b6b9 100755 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -998,7 +998,7 @@ def usage(exit_nonzero: bool=True) -> None: respect __all__) --include-private generate stubs for objects and members considered private - (single leading undescore and no trailing underscores) + (single leading underscore and no trailing underscores) --doc-dir PATH use .rst documentation in PATH (this may result in better stubs in some cases; consider setting this to DIR/Python-X.Y.Z/Doc/library) diff --git a/mypy/subtypes.py b/mypy/subtypes.py index c45a0fd94071..92c7bb2f49f4 100644 --- a/mypy/subtypes.py +++ b/mypy/subtypes.py @@ -608,7 +608,7 @@ def is_callable_compatible(left: CallableType, right: CallableType, The two calls are similar in that they both check the function arguments in the same direction: they both run `is_subtype(argument_from_g, argument_from_f)`. - However, the two calls differ in which direction they check things likee + However, the two calls differ in which direction they check things like keyword arguments. For example, suppose f and g are defined like so: def f(x: int, *y: int) -> int: ... diff --git a/mypy/traverser.py b/mypy/traverser.py index d4060852fe48..5c894de73654 100644 --- a/mypy/traverser.py +++ b/mypy/traverser.py @@ -17,7 +17,7 @@ class TraverserVisitor(NodeVisitor[None]): """A parse tree visitor that traverses the parse tree during visiting. - It does not peform any actions outside the traversal. Subclasses + It does not perform any actions outside the traversal. Subclasses should override visit methods to perform actions during traversal. Calling the superclass method allows reusing the traversal implementation. diff --git a/mypy/treetransform.py b/mypy/treetransform.py index 140d514e4138..c9c83f98c22d 100644 --- a/mypy/treetransform.py +++ b/mypy/treetransform.py @@ -94,7 +94,7 @@ def visit_func_def(self, node: FuncDef) -> FuncDef: # These contortions are needed to handle the case of recursive # references inside the function being transformed. - # Set up placholder nodes for references within this function + # Set up placeholder nodes for references within this function # to other functions defined inside it. # Don't create an entry for this function itself though, # since we want self-references to point to the original @@ -584,7 +584,7 @@ def types(self, types: List[Type]) -> List[Type]: class FuncMapInitializer(TraverserVisitor): """This traverser creates mappings from nested FuncDefs to placeholder FuncDefs. - The placholders will later be replaced with transformed nodes. + The placeholders will later be replaced with transformed nodes. """ def __init__(self, transformer: TransformVisitor) -> None: diff --git a/mypy/types.py b/mypy/types.py index 1d47117d4991..209cb860aecb 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -269,7 +269,7 @@ def accept(self, visitor: 'TypeVisitor[T]') -> T: return visitor.visit_type_list(self) def serialize(self) -> JsonDict: - assert False, "Sythetic types don't serialize" + assert False, "Synthetic types don't serialize" _dummy = object() # type: Any @@ -812,7 +812,7 @@ def max_fixed_args(self) -> int: def max_possible_positional_args(self) -> int: """Returns maximum number of positional arguments this method could possibly accept. - This takes into acount *arg and **kwargs but excludes keyword-only args.""" + This takes into account *arg and **kwargs but excludes keyword-only args.""" if self.is_var_arg or self.is_kw_arg: return sys.maxsize blacklist = (ARG_NAMED, ARG_NAMED_OPT) @@ -1211,7 +1211,7 @@ def accept(self, visitor: 'TypeVisitor[T]') -> T: return visitor.visit_star_type(self) def serialize(self) -> JsonDict: - assert False, "Sythetic types don't serialize" + assert False, "Synthetic types don't serialize" class UnionType(Type): @@ -1666,7 +1666,7 @@ def visit_overloaded(self, t: Overloaded) -> Type: if isinstance(new, CallableType): items.append(new) else: - raise RuntimeError('CallableType expectected, but got {}'.format(type(new))) + raise RuntimeError('CallableType expected, but got {}'.format(type(new))) return Overloaded(items=items) def visit_type_type(self, t: TypeType) -> Type: @@ -2050,7 +2050,7 @@ def callable_type(fdef: mypy.nodes.FuncItem, fallback: Instance, def get_typ_args(tp: Type) -> List[Type]: - """Get all type arguments from a parameterizable Type.""" + """Get all type arguments from a parametrizable Type.""" if not isinstance(tp, (Instance, UnionType, TupleType, CallableType)): return [] typ_args = (tp.args if isinstance(tp, Instance) else @@ -2060,7 +2060,7 @@ def get_typ_args(tp: Type) -> List[Type]: def set_typ_args(tp: Type, new_args: List[Type], line: int = -1, column: int = -1) -> Type: - """Return a copy of a parameterizable Type with arguments set to new_args.""" + """Return a copy of a parametrizable Type with arguments set to new_args.""" if isinstance(tp, Instance): return Instance(tp.type, new_args, line, column) if isinstance(tp, TupleType): diff --git a/mypy/typestate.py b/mypy/typestate.py index 1077d9a754ed..337aac21d714 100644 --- a/mypy/typestate.py +++ b/mypy/typestate.py @@ -131,7 +131,7 @@ def _snapshot_protocol_deps(cls) -> Dict[str, Set[str]]: The first kind is generated immediately per-module in deps.py (see also an example there for motivation why it is needed). While two other kinds are generated here after all - modules are type checked anf we have recorded all the subtype checks. To understand these + modules are type checked and we have recorded all the subtype checks. To understand these two kinds, consider a simple example: class A: