Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos discovered by codespell #18387

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ repos:
hooks:
- id: check-dependabot
- id: check-github-workflows
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
cclauss marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/rhysd/actionlint
rev: v1.7.4
hooks:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ similarly supported via generics (Python 3.12 syntax):

.. code-block:: python

from colletions.abc import Callable
from collections.abc import Callable
from typing import Any

def route[F: Callable[..., Any]](url: str) -> Callable[[F], F]:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/more_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ program:
The ``summarize([])`` call matches both variants: an empty list could
be either a ``list[int]`` or a ``list[str]``. In this case, mypy
will break the tie by picking the first matching variant: ``output``
will have an inferred type of ``float``. The implementor is responsible
will have an inferred type of ``float``. The implementer is responsible
for making sure ``summarize`` breaks ties in the same way at runtime.

However, there are two exceptions to the "pick the first match" rule.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/runtime_troubles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ libraries if types are generic only in stubs.
Using types defined in stubs but not at runtime
-----------------------------------------------

Sometimes stubs that you're using may define types you wish to re-use that do
Sometimes stubs that you're using may define types you wish to reuse that do
not exist at runtime. Importing these types naively will cause your code to fail
at runtime with ``ImportError`` or ``ModuleNotFoundError``. Similar to previous
sections, these can be dealt with by using :ref:`typing.TYPE_CHECKING
Expand Down
2 changes: 1 addition & 1 deletion mypy/argmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,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)
Expand Down
2 changes: 1 addition & 1 deletion mypy/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,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)
Expand Down
2 changes: 1 addition & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,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()
Expand Down
2 changes: 1 addition & 1 deletion mypy/semanal_namedtuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,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
Expand Down
2 changes: 1 addition & 1 deletion mypy/semanal_newtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
"""
Expand Down
2 changes: 1 addition & 1 deletion mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,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("*"))

Expand Down
2 changes: 1 addition & 1 deletion mypy/suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mypyc/codegen/emitfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def generate_native_function(
# generates them will add instructions between the branch and the
# next label, causing the label to be wrongly removed. A better
# solution would be to change the IR so that it adds a basic block
# inbetween the calls.
# in between the calls.
is_problematic_op = isinstance(terminator, Branch) and any(
isinstance(s, GetAttr) for s in terminator.sources()
)
Expand Down
4 changes: 2 additions & 2 deletions mypyc/doc/dev-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ pretty-printed IR into `build/ops.txt`. This is the final IR that
includes the output from exception and reference count handling
insertion passes.

We also have tests that verify the generate IR
We also have tests that verify the generated IR
(`mypyc/test-data/irbuild-*.text`).

## Type-checking Mypyc
Expand Down Expand Up @@ -284,7 +284,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 generated 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
Expand Down
2 changes: 1 addition & 1 deletion mypyc/irbuild/prebuildvisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
self.decorators_to_remove: dict[FuncDef, list[int]] = decorators_to_remove

# A mapping of import groups (a series of Import nodes with
# nothing inbetween) where each group is keyed by its first
# nothing in between) where each group is keyed by its first
# import node.
self.module_import_groups: dict[Import, list[Import]] = {}
self._current_import_group: Import | None = None
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ force-exclude = '''
^/test-data
'''

[tool.codespell]
ignore-words-list = "ans,ccompiler,corus,fo,froms,haa,hax,notin,ot,statics,whet,zar"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.3.0 added inline ignores. We should probably use those for single occurrences like froms.

# codespell:ignore froms

skip = "./mypyc/external/*,*.pyi,*.test"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder if we should just skip the whole mypy/test/ and mypyc/test folders entirely.

Personally I'd also just move the config to .pre-commit-config.yaml directly. Don't think any one is ever running codespell outside pre-commit.

This also allows us to use the pre-commit files filter as well with exclude_types: [pyi, test] and exclude: ^(mypyc/external/|mypy/test|mypyc/test).


[tool.ruff]
line-length = 99
target-version = "py39"
Expand Down
Loading