Skip to content

Commit

Permalink
Fix minor typos in comments (#5183)
Browse files Browse the repository at this point in the history
  • Loading branch information
ceh authored and ilevkivskyi committed Jun 9, 2018
1 parent 922cca1 commit 2bb7dd8
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion extensions/mypy_extensions.py
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mypy/binder.py
Expand Up @@ -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).
Expand Down
6 changes: 3 additions & 3 deletions mypy/checker.py
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions mypy/checkexpr.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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.)
Expand Down
2 changes: 1 addition & 1 deletion mypy/checkmember.py
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mypy/errors.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mypy/exprtotype.py
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mypy/fastparse2.py
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mypy/nodes.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion mypy/plugins/attrs.py
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions mypy/semanal.py
Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mypy/semanal_pass1.py
Expand Up @@ -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.
"""

Expand Down
2 changes: 1 addition & 1 deletion mypy/semanal_pass3.py
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mypy/server/astmerge.py
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mypy/server/deps.py
Expand Up @@ -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
"<trigger> -> locations"):
<m.A.g> -> m.f
Expand Down Expand Up @@ -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():
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions mypy/server/update.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mypy/stubgen.py
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mypy/subtypes.py
Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/traverser.py
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions mypy/treetransform.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions mypy/types.py
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mypy/typestate.py
Expand Up @@ -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:
Expand Down

0 comments on commit 2bb7dd8

Please sign in to comment.