diff --git a/CHANGELOG.md b/CHANGELOG.md index 9632cb39a8b1..4e141dd8d624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,7 +119,7 @@ This feature was contributed by Jukka Lehtosalo (PR [17404](https://github.com/p ### Mypyc Improvements -Mypyc now supports the new syntax for generics introduced in Python 3.12 (see above). Another notable improvement is signficantly faster basic operations on `int` values. +Mypyc now supports the new syntax for generics introduced in Python 3.12 (see above). Another notable improvement is significantly faster basic operations on `int` values. * Support Python 3.12 syntax for generic functions and classes (Jukka Lehtosalo, PR [17357](https://github.com/python/mypy/pull/17357)) * Support Python 3.12 type alias syntax (Jukka Lehtosalo, PR [17384](https://github.com/python/mypy/pull/17384)) diff --git a/mypy/argmap.py b/mypy/argmap.py index e6700c9f1092..d48c0639b1b1 100644 --- a/mypy/argmap.py +++ b/mypy/argmap.py @@ -219,7 +219,7 @@ def expand_actual_type( self.tuple_index += 1 item = actual_type.items[self.tuple_index - 1] if isinstance(item, UnpackType) and not allow_unpack: - # An upack item that doesn't have special handling, use upper bound as above. + # An unpack item that doesn't have special handling, use upper bound as above. unpacked = get_proper_type(item.type) if isinstance(unpacked, TypeVarTupleType): fallback = get_proper_type(unpacked.upper_bound) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 22595c85e702..16c2e5e371e8 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -840,7 +840,7 @@ def validate_typeddict_kwargs( # Having an optional key not explicitly declared by a ** unpacked # TypedDict is unsafe, it may be an (incompatible) subtype at runtime. # TODO: catch the cases where a declared key is overridden by a subsequent - # ** item without it (and not again overriden with complete ** item). + # ** item without it (and not again overridden with complete ** item). self.msg.non_required_keys_absent_with_star(absent_keys, last_star_found) return result, always_present_keys diff --git a/mypy/join.py b/mypy/join.py index 5284be7dd2a1..e3965475e60d 100644 --- a/mypy/join.py +++ b/mypy/join.py @@ -498,7 +498,7 @@ def join_tuples(self, s: TupleType, t: TupleType) -> list[Type] | None: return items return None if s_unpack_index is not None and t_unpack_index is not None: - # The most complex case: both tuples have an upack item. + # The most complex case: both tuples have an unpack item. s_unpack = s.items[s_unpack_index] assert isinstance(s_unpack, UnpackType) s_unpacked = get_proper_type(s_unpack.type) diff --git a/mypy/messages.py b/mypy/messages.py index dadce149680e..736871d235e2 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -209,7 +209,7 @@ def are_type_names_disabled(self) -> bool: def prefer_simple_messages(self) -> bool: """Should we generate simple/fast error messages? - If errors aren't shown to the user, we don't want to waste cyles producing + If errors aren't shown to the user, we don't want to waste cycles producing complex error messages. """ return self.errors.prefer_simple_messages() diff --git a/mypy/nodes.py b/mypy/nodes.py index 4a5c7240fa83..19f908661d49 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -1166,7 +1166,7 @@ def __init__( self.keywords = dict(keywords) if keywords else {} self.analyzed = None self.has_incompatible_baseclass = False - # Used for error reporting (to keep backwad compatibility with pre-3.8) + # Used for error reporting (to keep backwards compatibility with pre-3.8) self.deco_line: int | None = None self.docstring: str | None = None self.removed_statements = [] diff --git a/mypy/plugins/common.py b/mypy/plugins/common.py index f0ff6f30a3b9..43caa6483236 100644 --- a/mypy/plugins/common.py +++ b/mypy/plugins/common.py @@ -164,7 +164,7 @@ def find_shallow_matching_overload_item(overload: Overloaded, call: CallExpr) -> def _get_callee_type(call: CallExpr) -> CallableType | None: - """Return the type of the callee, regardless of its syntatic form.""" + """Return the type of the callee, regardless of its syntactic form.""" callee_node: Node | None = call.callee diff --git a/mypy/plugins/enums.py b/mypy/plugins/enums.py index 816241fa6e9a..86e7f1f7b31e 100644 --- a/mypy/plugins/enums.py +++ b/mypy/plugins/enums.py @@ -129,7 +129,7 @@ def _implements_new(info: TypeInfo) -> bool: def enum_member_callback(ctx: mypy.plugin.FunctionContext) -> Type: - """By default `member(1)` will be infered as `member[int]`, + """By default `member(1)` will be inferred as `member[int]`, we want to improve the inference to be `Literal[1]` here.""" if ctx.arg_types or ctx.arg_types[0]: arg = get_proper_type(ctx.arg_types[0][0]) diff --git a/mypy/semanal.py b/mypy/semanal.py index e239fbf1f141..c515ae33d517 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -4056,7 +4056,7 @@ def analyze_type_alias_type_params( ) -> tuple[TypeVarLikeList, list[str]]: """Analyze type_params of TypeAliasType. - Returns declared unbound type variable expressions and a list of all decalred type + Returns declared unbound type variable expressions and a list of all declared type variable names for error reporting. """ if "type_params" in rvalue.arg_names: @@ -6060,7 +6060,7 @@ def visit_yield_expr(self, e: YieldExpr) -> None: def visit_await_expr(self, expr: AwaitExpr) -> None: if not self.is_func_scope() or not self.function_stack: # We check both because is_function_scope() returns True inside comprehensions. - # This is not a blocker, because some enviroments (like ipython) + # This is not a blocker, because some environments (like ipython) # support top level awaits. self.fail('"await" outside function', expr, serious=True, code=codes.TOP_LEVEL_AWAIT) elif not self.function_stack[-1].is_coroutine: diff --git a/mypy/semanal_namedtuple.py b/mypy/semanal_namedtuple.py index 768dd265b338..d2e7124c4c72 100644 --- a/mypy/semanal_namedtuple.py +++ b/mypy/semanal_namedtuple.py @@ -196,7 +196,7 @@ def check_namedtuple_classdef( # Something is incomplete. We need to defer this named tuple. return None types.append(analyzed) - # ...despite possible minor failures that allow further analyzis. + # ...despite possible minor failures that allow further analysis. if name.startswith("_"): self.fail( f"NamedTuple field name cannot start with an underscore: {name}", stmt diff --git a/mypy/semanal_newtype.py b/mypy/semanal_newtype.py index c9c0c46f7aee..0c717b5d9a0e 100644 --- a/mypy/semanal_newtype.py +++ b/mypy/semanal_newtype.py @@ -174,7 +174,7 @@ def analyze_newtype_declaration(self, s: AssignmentStmt) -> tuple[str | None, Ca def check_newtype_args( self, name: str, call: CallExpr, context: Context ) -> tuple[Type | None, bool]: - """Ananlyze base type in NewType call. + """Analyze base type in NewType call. Return a tuple (type, should defer). """ diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index 7ab500b4fe12..fbaa862bf721 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -241,7 +241,7 @@ def __init__( self.module_name = module_name if self.is_c_module: # Add additional implicit imports. - # C-extensions are given more lattitude since they do not import the typing module. + # C-extensions are given more latitude since they do not import the typing module. self.known_imports.update( { "typing": [ @@ -340,7 +340,7 @@ def get_pos_default(i: int, _arg: str) -> Any | None: # Add *args if present if varargs: arglist.append(ArgSig(f"*{varargs}", get_annotation(varargs))) - # if we have keyword only args, then wee need to add "*" + # if we have keyword only args, then we need to add "*" elif kwonlyargs: arglist.append(ArgSig("*")) diff --git a/mypy/suggestions.py b/mypy/suggestions.py index 268f3032fc9b..ca681b9cda8e 100644 --- a/mypy/suggestions.py +++ b/mypy/suggestions.py @@ -454,7 +454,7 @@ def get_guesses_from_parent(self, node: FuncDef) -> list[CallableType]: pnode = parent.names.get(node.name) if pnode and isinstance(pnode.node, (FuncDef, Decorator)): typ = get_proper_type(pnode.node.type) - # FIXME: Doesn't work right with generic tyeps + # FIXME: Doesn't work right with generic types if isinstance(typ, CallableType) and len(typ.arg_types) == len(node.arguments): # Return the first thing we find, since it probably doesn't make sense # to grab things further up in the chain if an earlier parent has it. diff --git a/mypy/test/update_data.py b/mypy/test/update_data.py index 2d66752f61bd..2e1a6a9b3d1d 100644 --- a/mypy/test/update_data.py +++ b/mypy/test/update_data.py @@ -69,7 +69,7 @@ def _iter_fixes( source_line = source_line[: comment_match.start("indent")] # strip old comment if reports: indent = comment_match.group("indent") if comment_match else " " - # multiline comments are on the first line and then on subsequent lines emtpy lines + # multiline comments are on the first line and then on subsequent lines empty lines # with a continuation backslash for j, (severity, msg) in enumerate(reports): out_l = source_line if j == 0 else " " * len(source_line) diff --git a/mypy/typeanal.py b/mypy/typeanal.py index 274b4b893a98..1d894a0f6720 100644 --- a/mypy/typeanal.py +++ b/mypy/typeanal.py @@ -940,7 +940,7 @@ def analyze_unbound_type_without_type_info( elif unbound_tvar: assert isinstance(sym.node, TypeVarLikeExpr) if sym.node.is_new_style: - # PEP 695 type paramaters are never considered unbound -- they are undefined + # PEP 695 type parameters are never considered unbound -- they are undefined # in contexts where they aren't valid, such as in argument default values. message = 'Name "{}" is not defined' name = name.split(".")[-1] diff --git a/mypyc/codegen/emit.py b/mypyc/codegen/emit.py index fce6896e8d11..97302805fd3b 100644 --- a/mypyc/codegen/emit.py +++ b/mypyc/codegen/emit.py @@ -195,7 +195,7 @@ def attr(self, name: str) -> str: return ATTR_PREFIX + name def object_annotation(self, obj: object, line: str) -> str: - """Build a C comment with an object's string represention. + """Build a C comment with an object's string representation. If the comment exceeds the line length limit, it's wrapped into a multiline string (with the extra lines indented to be aligned with diff --git a/mypyc/codegen/emitmodule.py b/mypyc/codegen/emitmodule.py index 1d8708912de5..bb24bc532558 100644 --- a/mypyc/codegen/emitmodule.py +++ b/mypyc/codegen/emitmodule.py @@ -699,7 +699,7 @@ def generate_export_table(self, decl_emitter: Emitter, code_emitter: Emitter) -> copy the contents into a local copy of the table (to eliminate the need for a pointer indirection when accessing it). - Then, all calls to functions in another group and accesses to statics + Then, all calls to functions in another group and accesses to statistics from another group are done indirectly via the export table. For example, a group containing a module b, where b contains a class B diff --git a/mypyc/doc/dev-intro.md b/mypyc/doc/dev-intro.md index d11df7068e91..b34d6e22b9d8 100644 --- a/mypyc/doc/dev-intro.md +++ b/mypyc/doc/dev-intro.md @@ -280,7 +280,7 @@ under `mypyc/lib-rt`. ## Inspecting Generated C -It's often useful to inspect the C code genenerate by mypyc to debug +It's often useful to inspect the C code generate by mypyc to debug issues. Mypyc stores the generated C code as `build/__native.c`. Compiled native functions have the prefix `CPyDef_`, while wrapper functions used for calling functions from interpreted Python code have diff --git a/mypyc/irbuild/ll_builder.py b/mypyc/irbuild/ll_builder.py index 0c9310e6a5ca..5d5bd7d13c67 100644 --- a/mypyc/irbuild/ll_builder.py +++ b/mypyc/irbuild/ll_builder.py @@ -1908,7 +1908,7 @@ def primitive_op( ) return self.call_c(c_desc, args, line, result_type) - # This primitve gets transformed in a lowering pass to + # This primitive gets transformed in a lowering pass to # lower-level IR ops using a custom transform function. coerced = [] diff --git a/mypyc/irbuild/match.py b/mypyc/irbuild/match.py index a1e671911ea5..fb49119c591e 100644 --- a/mypyc/irbuild/match.py +++ b/mypyc/irbuild/match.py @@ -124,7 +124,7 @@ def visit_or_pattern(self, pattern: OrPattern) -> None: def visit_class_pattern(self, pattern: ClassPattern) -> None: # TODO: use faster instance check for native classes (while still - # making sure to account for inheritence) + # making sure to account for inheritance) isinstance_op = ( fast_isinstance_op if self.builder.is_builtin_ref_expr(pattern.class_ref)