Skip to content

Add spellchecking with crate-ci/typos #3166

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

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ repos:
rev: v2.3.0
hooks:
- id: codespell
- repo: https://github.com/crate-ci/typos
rev: v1.28.4
hooks:
- id: typos
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
Expand Down
16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ force-exclude = '''
[tool.codespell]
ignore-words-list = 'astroid,crasher,asend'

[tool.typos]
default.extend-ignore-re = [
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
]

[tool.typos.default.extend-identifiers]
IPPROTO_ND = "IPPROTO_ND"
ERROR_INVALID_PARMETER = "ERROR_INVALID_PARMETER"
xn--caf-dma = "xn--caf-dma"
mis-nested = "miss-nested"

[tool.typos.default.extend-words]
astroid = "astroid"
crasher = "crasher"
asend = "asend"

[tool.ruff]
respect-gitignore = true
fix = true
Expand Down
4 changes: 1 addition & 3 deletions src/trio/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ async def getaddrinfo(
Any required IDNA encoding is handled before calling this function;
your implementation can assume that it will never see U-labels like
``"café.com"``, and only needs to handle A-labels like
``b"xn--caf-dma.com"``.

"""
``b"xn--caf-dma.com"``.""" # spellchecker:disable-line
Copy link
Member

Choose a reason for hiding this comment

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

xn--caf is both in extend-identifiers in pyproject.toml and has spellchecker:disable-line?

Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason extend-identifiers does does not work as I intended and continues to try replacing it, so I added spellchecker:disable-line there to solve the issue. If there would be a way to get extend-identifiers to do ignore that one like I intended, that would be a better solution.

Copy link
Member

Choose a reason for hiding this comment

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

in that case we should at least remove the non-functioning line in extend-identifiers, unless you wanna report it upstream.


@abstractmethod
async def getnameinfo(
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_core/_ki.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def remove(
) -> None:
self = selfref()
if self is not None:
try: # noqa: SIM105 # supressible-exception
try: # noqa: SIM105 # suppressible-exception
del self._data[k]
except KeyError:
pass
Expand Down
4 changes: 2 additions & 2 deletions src/trio/_core/_parking_lot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ParkingLot provides an abstraction for a fair waitqueue with cancellation
# and requeueing support. Inspiration:
# and requeuing support. Inspiration:
#
# https://webkit.org/blog/6161/locking-in-webkit/
# https://amanieu.github.io/parking_lot/
Expand Down Expand Up @@ -136,7 +136,7 @@ class ParkingLotStatistics:
@final
@attrs.define(eq=False)
class ParkingLot:
"""A fair wait queue with cancellation and requeueing.
"""A fair wait queue with cancellation and requeuing.

This class encapsulates the tricky parts of implementing a wait
queue. It's useful for implementing higher-level synchronization
Expand Down
6 changes: 3 additions & 3 deletions src/trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class CancelStatus:
# become effectively cancelled when they do, unless scope.shield
# is True. May be None (for the outermost CancelStatus in a call
# to trio.run(), briefly during TaskStatus.started(), or during
# recovery from mis-nesting of cancel scopes).
# recovery from miss-nesting of cancel scopes).
_parent: CancelStatus | None = attrs.field(default=None, repr=False, alias="parent")

# All of the CancelStatuses that have this CancelStatus as their parent.
Expand All @@ -362,7 +362,7 @@ class CancelStatus:

# Set to True on still-active cancel statuses that are children
# of a cancel status that's been closed. This is used to permit
# recovery from mis-nested cancel scopes (well, at least enough
# recovery from miss-nested cancel scopes (well, at least enough
# recovery to show a useful traceback).
abandoned_by_misnesting: bool = attrs.field(default=False, init=False, repr=False)

Expand Down Expand Up @@ -595,7 +595,7 @@ def _close(self, exc: BaseException | None) -> BaseException | None:
return new_exc
scope_task = current_task()
if scope_task._cancel_status is not self._cancel_status:
# Cancel scope mis-nesting: this cancel scope isn't the most
# Cancel scope miss-nesting: this cancel scope isn't the most
# recently opened by this task (that's still open). That is,
# our assumptions about context managers forming a stack
# have been violated. Try and make the best of it.
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ async def async_back_in_main() -> tuple[str, str]:
assert sniffio.current_async_library() == "trio"


def test_run_fn_as_system_task_catched_badly_typed_token() -> None:
def test_run_fn_as_system_task_caught_badly_typed_token() -> None:
with pytest.raises(RuntimeError):
from_thread_run_sync(
_core.current_time,
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def fix_one(qualname: str, name: str, obj: object) -> None:
# so don't bother.
class generic_function(Generic[RetT]):
"""Decorator that makes a function indexable, to communicate
non-inferrable generic type parameters to a static type checker.
non-inferable generic type parameters to a static type checker.

If you write::

Expand Down
Loading